aor firebase client
1.0.0
Firebase의 admin-on-rest 클라이언트.
npm install aor-firebase-client --save<Admin> 구성 요소의 매개 변수로 // in src/App.js
import React from 'react' ;
import { Admin , Resource } from 'admin-on-rest' ;
import { RestClient } from 'aor-firebase-client' ;
const firebaseConfig = {
apiKey : '<your-api-key>' ,
authDomain : '<your-auth-domain>' ,
databaseURL : '<your-database-url>' ,
storageBucket : '<your-storage-bucket>' ,
messagingSenderId : '<your-sender-id>'
} ;
const clientOptions = {
timestampFieldNames : {
createdAt : 'createdAt' ,
updatedAt : 'updatedAt'
} ,
trackedResources : [ {
name : 'posts' , // The name reference to be used in all other places in AOR
path : 'blog' , // The path in the database. If missing will use the name
public : true ,
uploadFields : [ ] // The string name of the field
} , 'contacts' ] // A single string assumes path and name as equal, non private and without upload fields
}
const App = ( ) => (
< Admin restClient = { RestClient ( trackedResources , clientOptions ) } >
< Resource name = "posts" list = { PostList } />
< Resource name = "contacts" list = { ContactList } />
</ Admin >
) ;
export default App ; 패키지를 사용하면 Admin 구성 요소의 옵션 인 authClient Prop를 구현하는 로그인/로그 아웃 프로세스를 관리 할 수 있습니다 (문서 참조).
localStorage 에 firebaseToken 저장합니다. 사용 가능한 구성 옵션은 다음과 같습니다.
userProfilePath : 사용자 프로파일에 대한 데이터베이스 경로. 기본값 /users/ . 슬래시를 염두에 두십시오.
userAdminProp : 사용자에게 관리자 권한이있는 경우 지적 할 데이터베이스 키. isAdmin 기본값
마지막 경로는 다음과 같습니다. {userProfilePath}/{uid}/{userAdminProp}
localStorageTokenName : Firebase 클라이언트 토큰을 보유하는 로컬 스토리지 식별자, 기본값 aorFirebaseClientToken
handleAuthStateChange : 인증 프로세스를 무시하는 방법
// in src/App.js
...
import { RestClient , AuthClient } from 'aor-firebase-client' ;
const firebaseConfig = {
apiKey : '<your-api-key>' ,
authDomain : '<your-auth-domain>' ,
databaseURL : '<your-database-url>' ,
storageBucket : '<your-storage-bucket>' ,
messagingSenderId : '<your-sender-id>'
} ;
const authConfig = {
userProfilePath : 'profiles' ,
userAdminProp : 'superuser'
}
const App = ( ) => (
< Admin restClient = { RestClient ( firebaseConfig ) } authClient = { AuthClient ( authConfig ) } >
< Resource name = "posts" list = { PostList } />
</ Admin >
) ;
export default App ;참고 : Authclient는 Firebase를 초기화하기 위해 RestClient를 사용해야합니다. 또는 RESTCLIENT를 사용하지 않고 다음과 같이 소방대를 초기화하도록 선택할 수 있습니다.
import { RestClient , AuthClient } from 'aor-firebase-client' ;
import firebase from 'firebase' ;
const firebaseConfig = {
apiKey : '<your-api-key>' ,
authDomain : '<your-auth-domain>' ,
databaseURL : '<your-database-url>' ,
storageBucket : '<your-storage-bucket>' ,
messagingSenderId : '<your-sender-id>'
} ;
firebase . initializeApp ( firebaseConfig ) ;
const App = ( ) => (
< Admin authClient = { AuthClient ( ) } >
< Resource name = "posts" list = { PostList } />
</ Admin >
) ;
export default App ; 이 라이브러리는 MIT 라이센스에 따라 라이센스가 부여됩니다.