import { addUser , getUser , updateUser , deleteUser , listUsers , listAllUsers } from './user-admin' ; import { isAuthenticated , isAuthorized } from "../auth" ; import { https } from 'firebase-functions' ; import * as express from 'express' ; import * as cors from 'cors' ; const appUsers = express ( ) ; appUsers . use ( express . json ( ) ) ; appUsers . use ( cors ( { origin : true } ) ) ; appUsers . get ( '/' , isAuthenticated , isAuthorized ( [ 'admin' ] ) , listAllUsers ) ; appUsers . post ( '/' , isAuthenticated , isAuthorized ( [ 'admin' ] , { allowRootEmail : true } ) , listUsers ) ; appUsers . post ( '/new' , isAuthenticated , isAuthorized ( [ 'admin' ] ) , addUser ) ; appUsers . get ( '/:uid' , isAuthenticated , isAuthorized ( [ 'admin' ] , { allowSameUser : true } ) , getUser ) ; appUsers . patch ( '/:uid' , isAuthenticated , isAuthorized ( [ 'admin' ] , { allowSameUser : true } ) , updateUser ) ; appUsers . delete ( '/:uid' , isAuthenticated , isAuthorized ( [ 'admin' ] , { allowSameUser : true } ) , deleteUser ) ; export const users = https . onRequest ( appUsers ) ;