server.js 571 B

1234567891011121314151617
  1. const app = require('../app');
  2. const db = require('../model/db');
  3. const createFolderIsExist = require('../helpers/create-directory');
  4. const PORT = process.env.PORT || 3000;
  5. db.then(() => {
  6. app.listen(PORT, async () => {
  7. const DIR_UPLOAD = process.env.DIR_UPLOAD;
  8. const DIR_IMAGES = process.env.DIR_IMAGES;
  9. await createFolderIsExist(DIR_UPLOAD);
  10. await createFolderIsExist(DIR_IMAGES);
  11. console.log(`Server running. Use our API on port: ${PORT}`);
  12. });
  13. }).catch((err) => {
  14. console.log(`Server not running. Error message: ${err.message}`);
  15. process.exit(1);
  16. });