🙇♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const app = express(); | |
| const config = require('./config'); | |
| const { PORT } = config; | |
| require('./cron-jobs.js'); | |
| app.get('/', (req, res) => { | |
| console.log('Run task by request'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| PORT: 3000 || process.env.PORT, | |
| JOB_SCHEDULE: '* * * * *' | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const config = require('./config'); | |
| const { JOB_SCHEDULE } = config; | |
| const cron = require('node-cron'); | |
| cron.schedule(JOB_SCHEDULE, () => { | |
| console.log('Run task every minute'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "node-cron-sample", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "start": "node app.js", | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "keywords": [], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const app = express(); | |
| const { initFilePathConfig } = require('./utils/file.util.js'); | |
| const { PORT } = require('../configs/server.config'); | |
| require('./utils/cron.util'); | |
| initFilePathConfig(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const IMAGE_PATH = './images'; | |
| const TMP_PATH = './tmp'; | |
| module.exports = { | |
| IMAGE_PATH, | |
| TMP_PATH | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const config = require('../../configs/server.config'); | |
| const { JOB_SCHEDULE } = config; | |
| const moment = require('moment'); | |
| const cron = require('node-cron'); | |
| const { | |
| moveFileToAnother, | |
| readDirectory, | |
| createUniqueFormatDirectory | |
| } = require('./file.util'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const { promisify } = require('util'); | |
| const { IMAGE_PATH, TMP_PATH } = require('../../configs/file.config'); | |
| const newExistFile = promisify(fs.exists); | |
| const initFilePathConfig = async () => { | |
| await existDirectory(IMAGE_PATH); | |
| await existDirectory(TMP_PATH); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const app = express(); | |
| const PORT = process.env.PORT || 3000; | |
| app.use(bodyParser.urlencoded({ extended: false })); | |
| app.use(bodyParser.json()); | |
| app.use('/api', require('./routes')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const { userController } = require('../controllers'); | |
| const router = express.Router(); | |
| router.get('/local-user', userController.getUsers); | |
| router.post('/local-user', userController.addUsers); | |
| router.get( | |
| '/json-placeholder-user', | |
| userController.getUsersFromJsonPlaceholder |
OlderNewer