tillhoffmann1411 / node-boilerplate Goto Github PK
View Code? Open in Web Editor NEWA boilerplate template for NodeJS projects.
License: MIT License
A boilerplate template for NodeJS projects.
License: MIT License
In user.model.ts UserSchema.pre('save'...) doesnt get called when using updateOne according to "Pre and post save() hooks are not executed on update(), findOneAndUpdate(), etc. " on https://mongoosejs.com/docs/middleware.html#order.
So a small fix:
UserSchema.pre('updateOne', async function (next) {
const user = this.getUpdate();
if(user.password) {
user.password = await bcrypt.hash(user.password, bcrypt.genSaltSync());
this.update({}, user).exec()
}
next()
});
Threre will be a better solution using the IUserSchema - but i dont know how to get there from the Query Object 💯
Irgendwann habe ich in offiziellen Vorträgen rausgefunden, dass für jegliche externe Bibliothek die man in den $PATH installiert ein best-practise ist, diese per Entrypoint aufzurufen.
Das hat den Vorteil, dass dann die Volumes schon gemounted sind, man muss also vorher kein Copy mehr machen und das wird ggf. vom Volume überschrieben (das ist aktuell der Fall). Außerdem werden beim Image-bauen teilweise Systembibliotheken vom HOST im RUN verwendet, was zu ekeligen Fehlern führen kann.
Hier also mal ein anderes Herangehen, damit hatte ich bisher die allerwenigsten Probleme:
Dockerfile
FROM node
ADD ./node_startup.sh /
RUN ["chmod", "+x", "/node_startup.sh"]
EXPOSE 3000
ENTRYPOINT ["/node_startup.sh"]
CMD [ "npm", "run", "start:watch" ]
node_startup.sh
#!/bin/bash
npm install
npm run build
exec "$@"
Auf macOS und Linux getestet, funktioniert problemlos. Windows... your thing ;)
The Token Object of JWT contains expires, but the cookie must also, otherwise its just working for one session.
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.