Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antonybudianto/express-firebase-middleware
:fire: Express middleware for your Firebase applications
https://github.com/antonybudianto/express-firebase-middleware
express express-middleware firebase firebase-admin firebase-auth middleware
Last synced: 3 months ago
JSON representation
:fire: Express middleware for your Firebase applications
- Host: GitHub
- URL: https://github.com/antonybudianto/express-firebase-middleware
- Owner: antonybudianto
- License: mit
- Created: 2017-01-07T04:19:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T03:11:11.000Z (about 2 years ago)
- Last Synced: 2024-04-30T03:21:51.128Z (9 months ago)
- Topics: express, express-middleware, firebase, firebase-admin, firebase-auth, middleware
- Language: JavaScript
- Homepage:
- Size: 1.21 MB
- Stars: 51
- Watchers: 5
- Forks: 9
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-firebase - Express Firebase Middleware - ExpressJS middleware for your Firebase (Helpers)
README
# Express Firebase Middleware
Express middleware for your Firebase applications.
[![npm version](https://badge.fury.io/js/express-firebase-middleware.svg)](https://badge.fury.io/js/express-firebase-middleware)
> Starting new express firebase project? try out [Express Firebase](https://github.com/antonybudianto/express-firebase) starter
## Minimum requirements
- Node 6 or later
- npm 3 or later
- Firebase account## How to use
1. Install the packages using npm
```sh
npm install express firebase-admin express-firebase-middleware
```Both `express` and `firebase-admin` are peerDependencies.
2. Require it in your express routes
```js
var firebaseMiddleware = require('express-firebase-middleware');router.use('/api', firebaseMiddleware.auth);
```3. Now make sure the client's requests have Authorization header like
```
Authorization: Bearer
```The client can [get the token](https://firebase.google.com/docs/auth/admin/verify-id-tokens) from their client SDK (Web, Android, iOS Firebase SDK)
4. When requesting, and token is valid, you can get the `user` object from response
```js
router.get('/api/hello', (req, res) => {
res.json({
message: `You're logged in as ${res.locals.user.email} with Firebase UID: ${res.locals.user.uid}`
});
});
```## Debug mode
By default, the middleware will log and output to console, you can disable them by setting
your environment variable for `APP_DEBUG` to `false`## License
MIT