Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vunamhung/fastify-boilerplate
Fastify + Typescript
https://github.com/vunamhung/fastify-boilerplate
fastify mongodb mongoose typescript
Last synced: about 1 month ago
JSON representation
Fastify + Typescript
- Host: GitHub
- URL: https://github.com/vunamhung/fastify-boilerplate
- Owner: vunamhung
- License: mit
- Created: 2020-09-22T21:19:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-24T15:21:31.000Z (7 months ago)
- Last Synced: 2024-06-24T17:14:39.943Z (7 months ago)
- Topics: fastify, mongodb, mongoose, typescript
- Language: TypeScript
- Homepage:
- Size: 1.15 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Getting Started
First, run the development server:
```bash
npm dev
```## Manual deploy to server
```bash
npm deploy
```## Run use pm2
### Start pm2 cluster
```bash
pm2 start ./dist/index.js --name fastify -i 3
```### Reload pm2 cluster
```bash
pm2 reload admin_api
```## API Rules
URI formats
- Forward slash separator (/) must be used to indicate a hierarchical
relationship
- A trailing forward slash (/) should not be included in URIs
- Hyphens (-) should be used to improve the readability of URIs
- Underscores (\_) should not be used in URIs
- Prefer all lowercase letters in a URI path
- Do not include file extensionsResource archetypes
- Document
- Collection
- Stores
- ControllerURI path
- Use singular nouns for document names
- Use plural nouns for collections and stores
- As controller names represent an action, use a verb or verb phrase for controller resources
- Do not use CRUD function names in URIsURI query
- Use the query to filter collections or stores
- Use the query to paginate collection or store resultsRequest methods
- Don't tunnel to other requests with the GET and POST methods
- Use the GET method to retrieve a representation of a resource
- Use the HEAD method to retrieve response headers
- Use the PUT method to update and insert a stored resource
- Use the PUT method to update mutable resources
- Use the POST method to create a new resource in a collection
- Use the POST method for controller's execution
- Use the DELETE method to remove a resource from its parent
- Use the OPTIONS method to retrieve metadataResponse status codes
- 200: (“OK”) must not be used to communicate errors in the response
body
- 201: (“Created”) must be used to indicate successful resource creation
- 202: (“Accepted”) must be used to indicate successful start of an
asynchronous action
- 204: (“No Content”) should be used when the response body is
intentionally empty
- 301: (“Moved Permanently”) should be used to relocate resources
- 303: (“See Other”) should be used to refer the client to a different URI
- 304: (“Not Modified”) should be used to preserve bandwidth
- 307: (“Temporary Redirect”) should be used to tell clients to resubmit
the request to another URI
- 400: (“Bad Request”) may be used to indicate nonspecific failure
- 401: (“Unauthorized”) must be used when there is a problem with the
client’s credentials
- 403: (“Forbidden”) should be used to forbid access regardless of
authorization state
- 404: (“Not Found”) must be used when a client’s URI cannot be mapped to a resource
- 405: (“Method Not Allowed”) must be used when the HTTP method is
not supported
- 406: (“Not Acceptable”) must be used when the requested media type
cannot be served
- 409: (“Conflict”) should be used to indicate a violation of resource state
- 500: (“Internal Server Error”) should be used to indicate API
malfunction