Skip to content

An express starter kit with support for es6+ features using babel

Notifications You must be signed in to change notification settings

benmalcom/express-babel-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Babel Starter

A starter scaffold for your express projects using babel so you can take advantage of es6+ features in a nodejs environment This scaffold does not in anyway enforce how you should structure your project. You can tweak it to suit your needs.

Project generated with express-generator.

It's a small improvement over babel's official guide and vmasto's express-babel

What's Included?

  • Expressjs as the web framework
  • Support for es6+(es2015, es2016, es2017....) features thanks to Babel
  • Your codes are automatically polyfilled based on your run time environment by babel-preset-env
  • There's linting option with ESlint
  • Testing with Mocha
  • Config module to store simple project configurations

Getting Started

# Clone the project

git clone https://github.com/benmalcom/express-babel-starter.git

cd express-babel-starter

# Make it your own

rm -rf .git && git init (for windows users, delete .git folder)

# Install dependencies

npm install

If you use Yarn, just replace npm with yarn in the commands.

Start Your development
npm run start:dev

This command starts a nodemon process for your server restart when a code change happens.

Linting

This scaffold uses ESlint. It extends google's eslint config. Feel free to use your own rules or extend any other desirable rule(e.g airbnb) You can run linting in watch mode with:

npm run lint

Note: npm run start:dev starts the server with linting in watch mode, you can remove it if need be.

Testing

This scaffold uses Mocha. It also uses Supertest to demonstrate a simple routing test suite. Feel free to remove the supertest if you don't wish to use it. You can start the test runner in watch mode with:

npm test
Todo
  • Environment Variables
  • Deployment
Disclosure

There has always been debates online whether to use babel-transpilled codes on the server or not. Personally, I think it's fine and I've found this setup to be a sensible approach in doing so. That said, I'd suggest to take anything you read online with a grain of salt and refrain from blindly using boilerplates without first investigating personally. Node is very rapidly converging with the latest ECMAScript specification, and there's mostly full native support for ES2015 and ES2016. The need to transpile on the server is way smaller nowadays, albeit the language is constantly improving and transpiling will probably always be a part of our workflow. At the time of this writing the main benefits are mainly ES6 module syntax and async/await without flags.

This opinion is adapted from vmasto in his express-babel project because I agree with it.

In any case, you can simply remove transpilation and keep everything else that this kit has to offer. If you see anything that needs improvement feel free to open an issue for discussion!