





npm install --save express-user-managerexpressApp parameter has the following constraints:apiMountPoint parameter allows you to specify the base API route. Every request to the API will be relative to this base route. The default is /api/users.customRoutes parameter is an object that allows customization of the routes.userManager.listen(expressApp) before setting up your app's custom 404 handler.init methodinit method provides a shortcut way to perform the setup and initialization steps above.async function that runs setup and initialization tasks, connects to the database, then starts listening for requests, all in a single step: await init(app, options);.config method) as the second argument.config method (See The config method)init(app, options) methodconfig method  NODE_ENV (string): The environment in which the app is running: development, production, staging, test, etc.API_MOUNT_POINT (string): The route under which to listen for API requests, default is: /api/usersPORT: The port on which the server is running (or should run, if using as a stand-alone server)DB_ENGINE: The database engine to use. Should be one of the supported databases. (See Built-in data stores)DB_ADAPTER: The adapter to use. Set it to mongoose if using MongoDB; Set it to sequelize otherwise.DB_STORAGE_PATH: Define this only when the DB_ENGINE is set to sqlite.DB_HOST: The database hostDB_USERNAME: The database userDB_PASSWORD: The database user's passwordDB_DBNAME: The name of the databaseDB_PORT: The port on which the database is runningDB_DEBUG: Set to true or a non-zero integer to display debug output for the database.EXIT_ON_DB_CONNECT_FAIL: Set to true or a non-zero integer if the app should exit if it is unable to establish a connection to the database.SESSION_SECRET (string)AUTH_TOKEN_SECRET (string)AUTH_TOKEN_EXPIRY (number): Authorization token expiry (in seconds)PASSWORD_MIN_LENGTH (number)PASSWORD_MAX_LENGTH (number)DISALLOWED_PASSWORDS: (array): A comma-separated list of weak/non-secure passwords that should not allowed to be used as passwordsconfig methodconfig method.apiMountPoint: (string) specifies the users API routes base routepassword: (object) for configuring minimum and maximum password length, as well as disallowed passwordsroutes: (object) for setting up custom API endpointsdb: (object) encapsulating database connection informationsecurity: (object) for configuring session and authorization tokens and expiryconfig if they are already defined using environment variables. The exception to this is routes, which cannot be set via an environment variable. However, you can set it using the third parameter to the call to listen(app, apiMountPoint, routes).config, the value set in config will take precedence and be used instead.apiMountPoint can be set (in increasing order of precedence):  routes property with the API endpoints to config: userManager.config({
  routes: customApiEndpoints
});
userManager.listen(expressApp, apiMountPoint); userManager.listen: userManager.listen(expressApp, apiMountPoint, customApiEndpoints)/:username is automatically appended to the end of this route)/:userId is automatically appended to the end of this route)userManager.get('middlewares');. This will return an object with the following middlewares:req, res, next.userManager.removeRequestHook(route [, callback]).userManager.removeResponseHook(route, [callback]);mariadb)mssql)mysql)postgres)sqlite)PASSWORD_MIN_LENGTH environment variablePASSWORD_MAX_LENGTH environment variableDISALLOWED_PASSWORDS environment variable/api/users base route (mount point)./api/users.Posted Dec 24, 2024
A user management and authentication library for Express apps. Automatically creates and adds relevant (customizable) API endpoints to an Express app. - simply…