Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Last active January 18, 2021 15:49
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 netsi1964/2cca3408efba669dc1c0a07d4b37c3ad to your computer and use it in GitHub Desktop.
Save netsi1964/2cca3408efba669dc1c0a07d4b37c3ad to your computer and use it in GitHub Desktop.
A deno script listning on port 8080 allowing to hit it with rest path: /:route/:id/:action
// deno run --allow-net mousse.ts
import { Mousse } from 'https://github.com/Tyrenn/mousse/raw/main/mod.ts';
let mousse = new Mousse({ port: 8080 });
async function handleRequest(c: any) {
const _body = {
...c.params,
};
const body = JSON.stringify(_body);
c.response = {
status: 200,
'content-type': 'application/json',
body,
};
}
mousse.get('/:route/:id/:action', handleRequest);
mousse.get('/:route/:id', handleRequest);
mousse.get('/:route', handleRequest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment