4.0.1 โข Published 2 years ago
@ulisesgascon/simple-api v4.0.1
About
A very simple HTTP API to build fast prototypes
โค๏ธ Awesome Features:
- Typical Sample API with all the expected things (cors, fast response, immutability, etc..) ๐ฉ
- Basic JSON storage without external dependencies or third party solutions ๐ฅ
- Great testing coverage ๐งช
- Easy to customize โ๏ธ
- Great Documentation with Swagger ๐
- Available as Npx, module, docker image and more... with a single command ๐ฆ
Available Routes
Important:
- By running
npm run sample:generateyou will regenerate a new TODOs dataset - The server allows CRUD Operations but this operations are not affecting the dataset at all
Endpoints:
GET /__/healthcheck healthGET /__/docsSwagger documentation for all the available endpointsGET /v1/todoList all TODOSPOST /v1/todoCreate a TODOGET /v1/todo/{id}Get a specific TODOPUT /v1/todo/{id}Update a specific TODOPATCH /v1/todo/{id}PAtch a specific TODO propertyDELETE /v1/todo/{id}Delete a specific TODO
PRO TIP Run simple-api and check the Swagger docs with payload details and great UI ๐ฟ
Usage
Command line ๐ช
Using Node.js's npx to start a simple api in local:
npx @ulisesgascon/simple-apiYou can specify the port:
npx @ulisesgascon/simple-api 3000Module ๐ฆ
Using @ulisesgascon/simple-api in your project:
const appInitialization = require('@UlisesGascon/simple-api')
;(async () => {
const app = await appInitialization()
app.listen(3000, () => console.log(`Server listening on port 3000!`))
})()You can use app to extend the routes as it is the Typical express application
PRO TIP By default Swagger validator will be disabled as adding new routes can be complicated, but you can enable it:
const appInitialization = require('@UlisesGascon/simple-api')
;(async () => {
const app = await appInitialization({
swaggerEnabled: true
})
app.listen(3000, () => console.log(`Server listening on port 3000!`))
})()Docker Version ๐ณ
Use Docker Hub:
# Pull the image from Docker Hub:
docker pull ulisesgascon/simple-api:latest
# Run container:
docker run -p 3000:3000 ulisesgascon/simple-api:latestTo build and run the container locally:
# Clone Repo:
git clone https://github.com/ulisesgascon/simple-api.git
# Change to repo's cloned directory:
cd simple-api
# Build Image locally:
docker build --no-cache -t ulisesgascon/simple-api:latest .
# Run container:
docker run -p 3000:3000 ulisesgascon/simple-api:latestDevelopment ๐
Clone
git clone https://github.com/UlisesGascon/simple-api.git
cd simple-apiInstall
nvm use
npm iStart
# Regular
npm run start
# prettier logs:
npm run devTest
npm run test:coverageLinting
npm run lint
npm run lint:fixFormatting
npm run format
npm run format:fixContributing
Please consult CONTRIBUTING for guidelines on contributing to this project.
Author
@ulisesgascon/simple-api ยฉ Ulises Gascรณn, Released under the MIT License.