Skip to content

karlodelarosa/deno-rest-api

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Deno + MySQL Rest API Sample

Simple Deno REST API

Documentation

https://dev.to/karlodelarosa3/deno-mysql-sample-2f00

Install Deno: (MacOS)

curl -fsSL https://deno.land/x/install/install.sh | sh

Run Deno

deno run --allow-net --allow-read --allow-write index.ts

Access Deno container

localhost:8000

Database

If you have your own database, just change the values db/MySqlClient.ts

Run Docker container

docker-compose up -d

Adminer

localhost:50000

DB Credentials

server: deno-db
user: root
password: root
db: deno-db

HTTP REQUEST

Set Header:

Content-Type: application/json

Get All Users

http://localhost:8000/users

Get User by ID

http://localhost:8000/user/:id

eg.

http://localhost:8000/user/1

POST

http://localhost:8000/user
Request Body
{
	"name": "John Doe",
	"country": "USA"
}

PUT

http://localhost:8000/user/:id

eg:

http://localhost:8000/user/1
Request Body
{
	"name": "Jane Doe",
	"country": "Japan"
}

DELETE

http://localhost:8000/user/:id

eg:

http://localhost:8000/user/1

About

Simple REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published