Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import express from 'express';
- import {Request, Response} from 'express';
- //import morgan from 'morgan';
- import * as fs from 'fs';
- import * as bodyParser from 'body-parser';
- import * as book from './controllers/bookController';
- const app = express();
- app.set('port', process.env.port || 3000);
- app.use(bodyParser.json());
- app.use(bodyParser.urlencoded({ extended : false }));
- /* app.listen(morgan('common', {
- stream: fs.createWriteStream('./access.log', {flags: 'a'})
- }));
- app.use(morgan('dev')); */
- //endpoints
- // API Endpoints
- app.get('/', book.allBooks)
- app.get('/:id', book.getBook)
- app.post('/', book.addBook)
- app.put('/:id', book.updateBook)
- app.delete('/:id', book.deleteBook)
- app.get('/', (req: Request, res: Response) => {
- res.send("returns all Books")});
- const server = app.listen(app.get('port'), () => {
- console.log('App is running on http://localhost:%d', app.get('port'));
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement