-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e38c59
commit 2181d33
Showing
1 changed file
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
Welcome to the Node wiki! Here you will find various information about this repo. | ||
|
||
## Node | ||
|
||
* [how to create a fullstack with another of our repos](https://github.com/weareopensource/weareopensource.github.io/wiki) | ||
|
||
## Doc | ||
|
||
* [Api](https://github.com/weareopensource/Node/blob/master/README.md#API) | ||
* [Errors](https://github.com/weareopensource/Node/blob/master/README.md#Errors) | ||
|
||
## Other informations | ||
|
||
* [Knowledges](https://github.com/weareopensource/Node/blob/master/KNOWLEDGES.md) | ||
* [Changelog](https://github.com/weareopensource/Node/blob/master/CHANGELOG.md) | ||
* [Licence](https://github.com/weareopensource/Node/blob/master/LICENSE.md) | ||
* [Contribute](https://github.com/weareopensource/weareopensource.github.io/wiki/Contribute) | ||
|
||
## WAOS | ||
|
||
* [Our Mindset](https://weareopensource.me/introduction/) | ||
* [Our Roadmap](https://github.com/weareopensource/weareopensource.github.io/projects) | ||
* [Us](https://github.com/weareopensource/weareopensource.github.io/wiki/Us) | ||
* [Help Us](https://github.com/weareopensource/weareopensource.github.io/wiki/HelpUs) | ||
|
||
# Doc | ||
|
||
## API | ||
|
||
### API answers rules : | ||
|
||
#### success | ||
|
||
`responses.success(res, 'task created')({});` | ||
|
||
body : | ||
|
||
``` | ||
{ | ||
type: 'success', | ||
message: 'task created' | ||
data: {} | ||
} | ||
``` | ||
|
||
#### error | ||
|
||
`responses.error(res, 422, 'task creation failed')({err});` | ||
|
||
body : | ||
|
||
``` | ||
{ | ||
type: 'error', | ||
message: 'task creation failed' | ||
error: {err} | ||
} | ||
``` | ||
|
||
## Errors | ||
|
||
#### controller | ||
|
||
`responses.error(res, 422, errors.getMessage(err))({err});` | ||
|
||
body : | ||
|
||
``` | ||
{ | ||
type: 'error', | ||
message: 'task creation failed' | ||
error: {err} | ||
} | ||
``` | ||
|
||
#### schema errors | ||
|
||
`responses.error(res, 422, errors.getMessage(err))({err});` | ||
|
||
body : | ||
|
||
``` | ||
{ | ||
type: 'error', | ||
message: 'schema validation error', | ||
error: { | ||
original: { | ||
title: 2, | ||
description: 'do something about something else' | ||
}, | ||
details: [{ | ||
message: 'title must be a string', | ||
type: 'string.base' | ||
} ] | ||
} | ||
} | ||
``` | ||
|
||
#### service & others errors | ||
|
||
`throw new AppError('invalid user or password');` | ||
|
||
body : | ||
|
||
``` | ||
{ | ||
type: 'error', | ||
message: 'Something went wrong', | ||
error: { | ||
details: [{ | ||
message: 'invalid user or password', | ||
}] | ||
} | ||
} | ||
``` | ||
|
||
#### Authentication errors | ||
|
||
status : 401 | ||
error : | ||
|
||
``` | ||
{ | ||
text: 'Unauthorized' | ||
} | ||
``` |