1.0.0 • Published 4 years ago
@softwits/user-authentication-authorization v1.0.0
Send JWT token in the name of 'Authorization'
How to use it?
import { AuthRoutes, SoftwitsAuthentication } from '@softwits/user-management';
import { MongoConnectionProps, MongoDB } from '@softwits/databases';
new MongoDB().connect(db);
const serverOpts = {
port: 9000,
};
// To intialize local strategy
new SoftwitsAuthentication();
to setup routes
import { graphqlServer } from '@softwits/express-graphql-rest';
graphqlServer.createApolloServer(schema, resolvers, null, { port: 4000 }, null, [new AuthRoutes()]);
or
import { expressServer } from '@softwits/express-graphql-rest';
expressServer.startServer(serverOpts, [new AuthRoutes()]);
Validate routes
httpServer.get(
'/test',
(req: Request, res: Response, next: NextFunction) => {
res.send('success');
},
[authenticate('jwtVerify', { session: false })],
);
use authenticate('jwtVerify', { session: false })
as middleware in the routes
1.0.0
4 years ago