Skip to content

sroehrl/deno-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno RESTful POC

Experiment on how working with deno as a REST-API might look like.

ORM: denodb

Check out https://eveningkid.com/denodb-docs/docs/getting-started

Authentication

Check out https://deno.land/x/djwt

Usage:

https://raw.githubusercontent.com/sroehrl/deno-rest-api/master/mod.ts

import {ClientRequest, Method, startSimpleServer} from 'https://raw.githubusercontent.com/sroehrl/deno-rest-api/master/mod.ts';
startSimpleServer([
    {
        path:'/api/test',
        method:Method.GET,
        handler:() => ({test:'me'})
    },
    {
        path: '/api/read-parmas/:name',
        method: Method.GET,
        handler: (client: ClientRequest) => ({name:client.params.name})
    },
    {
        path: '/api/yes-or-no',
        method: Method.POST,
        handler: (client: ClientRequest) => {
            const answer = {
                approval: client.body.approval === 'yes' ? 'yes' : 'no'
            }
            return answer;
        }
    }
])

to run

deno run --allow-net --allow-read --allow-write --watch {your-file.ts}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published