Skip to content

Instantly share code, notes, and snippets.

@sydcanem
Last active September 6, 2020 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sydcanem/8c5d3577503fe49511a513a6d27842b3 to your computer and use it in GitHub Desktop.
Save sydcanem/8c5d3577503fe49511a513a6d27842b3 to your computer and use it in GitHub Desktop.
Express ES6 Boilerplate

Express Boilerplate in ES6

Because it's hard to memorize boilerplates...

import { Router } from 'express';
export default function() {
const api = Router();
api.post('/echo', (req, res) => {
res.status(204).send('No content');
});
return api;
}
import express from 'express';
import path from 'path';
import cors from 'cors';
import bodyParser from 'body-parser';
import api from './api';
const app = express();
app.use(express.static(path.join(__dirname, '../public')));
app.use(cors());
app.use(bodyParser());
app.use('/api', api());
export default app;
import http from 'http';
import app from './app';
const server = http.createServer(app);
socket(server);
server.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment