@devowt/siesta
A chilled out ReST API framework for Node.
This package contains the siesta core framework modules.
Gettings started
npm install @devowt/siesta --save
yarn add @devowt/siesta
Siesta is actually written in TypeScript so if you prefer so type definitions are also made available:
npm install @types/siesta --save-dev
yarn add @types/siesta --dev
Now we can configure a basic server
// import the framework
import * as $ from 'siesta';
// create a new api server
const api = $.server();
// get a message
app.get('/hello/:name', ({ name }) => {
const model = {
message: `Hello, ${name}`
};
// return the response model.
return model;
});
// create something
app.post('/something', async (model) => {
let id = await someStorageMechanism.addSomething(model);
// return the response model.
return id;
});
// when process.env !== production port will be 3001
app.listen();