|
| 1 | +Welcome to the Node wiki! Here you will find various information about this repo. |
| 2 | + |
| 3 | +## Node |
| 4 | + |
| 5 | +* [how to create a fullstack with another of our repos](https://github.com/weareopensource/weareopensource.github.io/wiki) |
| 6 | + |
| 7 | +## Doc |
| 8 | + |
| 9 | +* [Api](https://github.com/weareopensource/Node/blob/master/README.md#API) |
| 10 | +* [Errors](https://github.com/weareopensource/Node/blob/master/README.md#Errors) |
| 11 | + |
| 12 | +## Other informations |
| 13 | + |
| 14 | +* [Knowledges](https://github.com/weareopensource/Node/blob/master/KNOWLEDGES.md) |
| 15 | +* [Changelog](https://github.com/weareopensource/Node/blob/master/CHANGELOG.md) |
| 16 | +* [Licence](https://github.com/weareopensource/Node/blob/master/LICENSE.md) |
| 17 | +* [Contribute](https://github.com/weareopensource/weareopensource.github.io/wiki/Contribute) |
| 18 | + |
| 19 | +## WAOS |
| 20 | + |
| 21 | +* [Our Mindset](https://weareopensource.me/introduction/) |
| 22 | +* [Our Roadmap](https://github.com/weareopensource/weareopensource.github.io/projects) |
| 23 | +* [Us](https://github.com/weareopensource/weareopensource.github.io/wiki/Us) |
| 24 | +* [Help Us](https://github.com/weareopensource/weareopensource.github.io/wiki/HelpUs) |
| 25 | + |
| 26 | +# Doc |
| 27 | + |
| 28 | +## API |
| 29 | + |
| 30 | +### API answers rules : |
| 31 | + |
| 32 | +#### success |
| 33 | + |
| 34 | +`responses.success(res, 'task created')({});` |
| 35 | + |
| 36 | +body : |
| 37 | + |
| 38 | +``` |
| 39 | +{ |
| 40 | + type: 'success', |
| 41 | + message: 'task created' |
| 42 | + data: {} |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +#### error |
| 47 | + |
| 48 | +`responses.error(res, 422, 'task creation failed')({err});` |
| 49 | + |
| 50 | +body : |
| 51 | + |
| 52 | +``` |
| 53 | +{ |
| 54 | + type: 'error', |
| 55 | + message: 'task creation failed' |
| 56 | + error: {err} |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +## Errors |
| 61 | + |
| 62 | +#### controller |
| 63 | + |
| 64 | +`responses.error(res, 422, errors.getMessage(err))({err});` |
| 65 | + |
| 66 | +body : |
| 67 | + |
| 68 | +``` |
| 69 | +{ |
| 70 | + type: 'error', |
| 71 | + message: 'task creation failed' |
| 72 | + error: {err} |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +#### schema errors |
| 77 | + |
| 78 | +`responses.error(res, 422, errors.getMessage(err))({err});` |
| 79 | + |
| 80 | +body : |
| 81 | + |
| 82 | +``` |
| 83 | +{ |
| 84 | + type: 'error', |
| 85 | + message: 'schema validation error', |
| 86 | + error: { |
| 87 | + original: { |
| 88 | + title: 2, |
| 89 | + description: 'do something about something else' |
| 90 | + }, |
| 91 | + details: [{ |
| 92 | + message: 'title must be a string', |
| 93 | + type: 'string.base' |
| 94 | + } ] |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +#### service & others errors |
| 100 | + |
| 101 | +`throw new AppError('invalid user or password');` |
| 102 | + |
| 103 | +body : |
| 104 | + |
| 105 | +``` |
| 106 | +{ |
| 107 | + type: 'error', |
| 108 | + message: 'Something went wrong', |
| 109 | + error: { |
| 110 | + details: [{ |
| 111 | + message: 'invalid user or password', |
| 112 | + }] |
| 113 | + } |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +#### Authentication errors |
| 118 | + |
| 119 | +status : 401 |
| 120 | +error : |
| 121 | + |
| 122 | +``` |
| 123 | +{ |
| 124 | + text: 'Unauthorized' |
| 125 | +} |
| 126 | +``` |
0 commit comments