본문 바로가기

express

(30)
Excuting some work on same time everyday. [Scheduling] Scheduled work Situation : Need to do some work on same time for every day, In our site, we need to bring upcomming match datas everyday How to : use "node-schedule" What is node-schedule Node Schedule is for time-based scheduling, not interval-based scheduling. There is another tool can use for scheduling. That is "setInterval". "setInterval" is used for example: "run this function every 5 minu..
Divide DB by the 'env' Divide Database by the environment Situation: I want to use another DB for TDD. Using just one DB for any enviroment is not that good. because anyone or any team mates can delete or edit datas without discussion. Before check enviroment status, We need to know how the environment managed. Node.js allow us to check what is the environment is now. How? with this. process.env.NODE_ENVAnd also we ca..
What is node.js?[not done]
passport-facebook with JWT [Express] When we use SOCIAL LOGIN (like facebook, google login) we can use passport.js there is a lot of strategy to use(Facebook Strategy, github Strategy etc..). these strategies help us to login by these sites. you can remember these process. you already used it a lot. process of passport-facebook (use session) choose what strategy to login with click choosed strategy link redirect to strategy site(fa..
body-parser[Middleware] body-parser: Parse incoming request bodies in a middleware before your handlers, available under the req.body property. when you use body-parser, you need to put any options. if you dont, you will get a sentence like "body-parser deprecated undefined extended: provide extended option" so we usually put ".urlencoded({ extended: true or false })" this means if "extended : true", this means req.bod..
How to test passport-facebook /Social login test [TDD] How to do test passport social login? Facebook delegates login instead of me. I just needed to set passport stuffs in my application code. If I set passport code in my app, and If I send request 'login', Facebook does work. like redirecting to login page, validating Id/Password input, and showing result page etc. these processes is not in my application code. so I didn't know what to do for test..
How to show joined models [mongoose] MongoDB doesn't have "join". Instead join, mongoose Uses "virtaul" and "populate" First, take a look at models. ProductSchema // app/model/product.js const ProductSchema = new mongoose.Schema( { name: { type: String, maxlength: 50 }, description: { type: String, maxlength: 1000 }, { toJSON: { virtuals: true }, toObject: { virtuals: true }, } }); // Reverse populate with virtuals ProductSchema.vi..
Permission check on user's actions [Express, Node] There are some actions need permisstion or Authentication. Like Deleting, Updating, Getting information, adminning user. etc. How we check permission or authentication? We can make middleware doing permission checking. and put it in Router. const { protect, authroize } = require('../middleware/auth'); router.use(protect); // Here router.use(authroize('admin')); // Here router .route('/') .get(ge..