Table of Contents
A Restful API backend application built with Express.js and TypeScript, offering robust and scalable solutions for user authentication and data management.
- mean Stack Architecture: Follows the mean stack for a well-structured and maintainable project
- Schema and Data Validation: Utilizes Joi for defining schemas and validating data, including environment variables (process.env)
- MongoDB Integration: Employs Mongoose to model and interact with MongoDB Atlas
- User Authentication: Supports user sign-up, sign-in, and logout functionalities
- Email Service with OTP: Built with Nodemailer and Brevo, allowing the generation and sending of OTP codes via email
- CRUD Operations: Provides create, read, update, and delete (CRUD) operations for user data in the MongoDB Atlas database
- Role-Based Access Control: Implements role-based access control using Bearer Authentication for sensitive API endpoints, such as changing user roles and deleting users
- Request Validation Middleware: Includes middleware for validating incoming requests to ensure data integrity and security
- JWT Authentication: Generates JSON Web Tokens (JWT) using the jsonwebtoken library for secure user authentication and authorization
some steps
Install packages
yarn
Launch at localhost in development mode
yarn dev
The full error message:
node_modules\@hapi\hoek\lib\error.js:23
Error.captureStackTrace(this, exports.assert);
^
Error: Method no longer accepts array arguments: valid
When passing the array Object.values(UserRole)
into Joi.string().valid()
export const UserRole = {
ADMIN: 'admin',
visitor: 'user',
GUEST: 'guest'
} as const;
...
role: Joi.string().valid(Object.values(UserRole)),
...
Use Spread syntax (...) to expand the array.
...
role: Joi.string().valid(...Object.values(UserRole)),
...
Distributed under the MIT License. See LICENSE.txt
for more information.