saisilinus / node-express-mongoose-typescript-boilerplate Goto Github PK
View Code? Open in Web Editor NEWA boilerplate for making production-ready RESTful APIs using Node.js, TypeScript, Express, and Mongoose
License: MIT License
A boilerplate for making production-ready RESTful APIs using Node.js, TypeScript, Express, and Mongoose
License: MIT License
I think maybe use should add a package "concurrently" as devDependencies.
And change dev script like this to achieve Hot Reload as dev script.
PS: your command "yarn compile:watch" maybe wrong when include "src".
`"dev": "concurrently "yarn compile:watch" "yarn pre:dev"",
"pre:dev": "cross-env NODE_ENV=development nodemon --experimental-modules --es-module-specifier-resolution=node dist/index.js",
"compile:watch": "tsc --build --watch",`
An attacker may use the "forgot-password" request to know whether an account with the targeted email exists or not.
Whether the email is in use or not, the requestor should probably receive the same response.
Something like this:
export const generateResetPasswordToken = async (email: string): Promise<string> => {
const user = await userService.getUserByEmail(email);
if (!user) {
// While it's an error, the form submitter will not know and will receive a pseudo-success message
throw new ApiError(
httpStatus.OK,
'If this email is registered, it will receive the instructions on resetting the password.'
);
}
const expires = moment().add(config.jwt.resetPasswordExpirationMinutes, 'minutes');
const resetPasswordToken = generateToken(user.id, expires, tokenTypes.RESET_PASSWORD);
await saveToken(resetPasswordToken, user.id, expires, tokenTypes.RESET_PASSWORD);
return resetPasswordToken;
};
Describe the bug
When installing the project, the http-status and helmet types are missing.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No type errors should be shown
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
This PR should fix this: #53
Describe the bug
A clear and concise description of what the bug is.
router .route('/explore/:customerId') .get(validate(productValidation.exploreCrafts), productController.exploreCrafts)
Here's my route and here's what I'm getting in objectId validation value:
https://i.imgur.com/aUvfj0u.png
Expected behavior
Is there any way I can still use route as it is and only params gets picked up?
Adding this makes it easy to use the correct link in development vs production.
Also changing it along with the other options is easier.
Example:
const resetPasswordUrl = `http://${config.frontUrl}/reset-password?token=${token}`;
When I try to dockerize the application the composing errors on the node-app part. No directory is created and nothing happens. Besides the console showing the key word error not further stack trace is displayed. So I would be interested if this is a general issue or if my environment is the issue.
Module | Version |
---|---|
node | v16.15.1 |
yarn | v1.22.19 |
npm | v8.18.0 |
Type | MacBook Pro (16", 2021) |
OS | macOS Monterey v12.6 |
Chip | Apple M1 Pro |
$ git clone https://github.com/saisilinus/node-express-mongoose-typescript-boilerplate.git
$ yarn install
$ cp .env.example .env
$ yarn docker:dev
Hi,
thanks a lot for this template, very good work.
I try to use alias path in the project, I add this in tsconfig.json under compilerOptions:
"paths": { "~/*": ["./src/*"], },
but when run yarn dev
I get this error:
[0]
[1] node:internal/errors:490
[1] ErrorCaptureStackTrace(err);
[1] ^
[1]
[1] Error [ERR_MODULE_NOT_FOUND]: Cannot find package '~' imported from /stuff/dist/index.js
[1] at new NodeError (node:internal/errors:399:5)
[1] at packageResolve (node:internal/modules/esm/resolve:889:9)
[1] at moduleResolve (node:internal/modules/esm/resolve:938:20)
[1] at defaultResolve (node:internal/modules/esm/resolve:1153:11)
[1] at nextResolve (node:internal/modules/esm/loader:163:28)
[1] at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
[1] at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
[1] at ModuleWrap. (node:internal/modules/esm/module_job:77:40)
[1] at link (node:internal/modules/esm/module_job:76:36) {
[1] code: 'ERR_MODULE_NOT_FOUND'
[1] }
I have tried several solutions but none have solved the problem. could anyone help me.
thank you very much
Hi,
I'm updated all package for this project, but after update mongoose i get error type, please check issue and if you can helped to fix this problem.
user.model.ts(58,19): error TS2345: Argument of type '(schema: Schema) => void' is not assignable to parameter of type 'PluginFunction<IUserDoc, IUserModel, any, any, any, any>'.
[0] Types of parameters 'schema' and 'schema' are incompatible.
[0] Type 'Schema<IUserDoc, IUserModel, any, any, any, any, "type", IUserDoc>' is not assignable to type 'Schema<any, Model<any, any, any, any, any>, {}, {}, {}, {}, "type", { [x: string]: any; }>'.
[0] Types of property 'obj' are incompatible.
[0] Type '{ _id?: SchemaDefinitionProperty | undefined; __v?: SchemaDefinitionProperty | undefined; id?: SchemaDefinitionProperty | undefined; ... 5 more ...; isEmailVerified?: SchemaDefinitionProperty<...> | undefined; }' is not assignable to type '{ [path: string]: SchemaDefinitionProperty; } | { [x: string]: SchemaDefinitionProperty | undefined; }'.
[0] Type '{ _id?: SchemaDefinitionProperty | undefined; __v?: SchemaDefinitionProperty | undefined; id?: SchemaDefinitionProperty | undefined; ... 5 more ...; isEmailVerified?: SchemaDefinitionProperty<...> | undefined; }' is not assignable to type '{ [x: string]: SchemaDefinitionProperty | undefined; }'.
[0] Property 'isEmailVerified' is incompatible with index signature.
[0] Type 'SchemaDefinitionProperty' is not assignable to type 'SchemaDefinitionProperty | undefined'.
[0] Type 'false' is not assignable to type 'SchemaDefinitionProperty | undefined'.
Describe the bug
The app crashes when I start it.
To Reproduce
Steps to reproduce the behavior:
npx create-nodejs-ts-app back
cd back
yarn dev
Expected behavior
The app should work as expected.
Desktop :
Additional context
This is the same behaviour with yarn start
. I also tried to yarn compile
first but it didn't change anything.
Thanks for your help !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.