NPM package to create new pre-configured express app for REST API's from the command line. Download
(July 16, 2020) Now, you can choose a package manager npm or yar. π
(July 15, 2020) Now, you can choose between JavaScript with EsLint setup and TypeScript with TsLint setup. ππ
install the package globally with this command.
npm i -g new-express-app
Run this command where you want to create the new app.
npx new-express-app
then answer the following Questions to configure your project:
? Enter Project Name:
? Enter version:
? Enter description:
? Enter author name:
? what language you want to use? # JavaScript or TypeScript
? choose a package Manager: # npm or yarn
? Want to initialise git?
? Want to install dotEnv?
? Want to install database driver? # MongoDB, Mongoose or None
? Want to initialise EsLint/Prettier? # if you chose JavaScript
? Want to initialise TsLint/Prettier? # if you chose TypeScript
- Express
- cors
- Express
- cors
- typescript
- ts-node
- dotenv
- mongoDB
- assert
- mongoose
- nodemon
- nodemon
- @types/node
- @types/express
- @types/cors
- EsLint / TsLint
- prettier
- required devDependencies for the past two devDependencies.
- @types/mongoose
- @types/mongodb
- @types/assert
.
βββ .env
βββ .eslintrc.json
βββ .gitignore
βββ package-lock.json
βββ package.json
βββ prettier.config.js
βββ src
βββ controllers
βΒ Β βββ controller.js
βββ index.js
βββ models
βββ routes
βββ router.js
4 directories, 9 files
.
βββ .env
βββ .gitignore
βββ .prettierrc.json
βββ package-lock.json
βββ package.json
βββ src
βΒ Β βββ controllers
βΒ Β βΒ Β βββ controller.ts
βΒ Β βββ index.ts
βΒ Β βββ models
βΒ Β βββ routes
βΒ Β βββ router.ts
βββ tsconfig.json
βββ tslint.json
4 directories, 10 files
const express = require('express');
const cors = require('cors');
const router = require('./routes/router');
const app = express();
app.use(express.urlencoded());
app.use(express.json());
app.use(cors({ origin: true, credentials: true }));
app.use('/', router);
app.listen(8080, () => {
console.log('Server Running');
});
const express = require('express');
const Controller = require('../controllers/controller');
const router = express.Router();
router.use('/', Controller.helloWorld);
module.exports = router;
exports.helloWorld = (req, res, next) => {
res.send('<h1>Hello World!</h1>');
};
{
"env": {
"node": true,
"commonjs": true,
"es2020": true
},
"extends": ["plugin:prettier/recommended", "airbnb-base"],
"parserOptions": {
"ecmaVersion": 11
},
"rules": {
"prettier/prettier": "error"
},
"plugins": ["prettier"]
}
module.exports = {
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'es5',
};
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Copyright 2020 Mahmoud .A Mahmoud. Licensed under the MIT License