-
Notifications
You must be signed in to change notification settings - Fork 2
Development guide
When you need to write a new REST API route:
- Add the route to
config/routes.js
. - Add the referred method to
api/v1/xxxx/your-method.js
with xxxx being the entity related to your method (cave, entrance, document, caver...) - In the method, if needed, use the CheckRightService. ✳️ The returned result must be (almost) always formatted by the ControllerService
treat
andtreatAndConvert
methods. If you need to send a response before hitting the ControllerService, use the custom responses in the/api/responses
folder (badRequest, notFound, ok and so on...) instead of usingres.status()
orres.send()
. - Add the appropriate policy / policies to
config/policies.js
. - If your method needs a database update (you need a new column or a new right for example), check if your local AND production databases are correctly set.
⚠️ Contact the Grottocenter administrators to update the production database: only them can do it! - Add your new route to
swaggerV1.yaml
(you can use https://editor.swagger.io/ to edit it properly). - Test, test and test your route, with correct data, with missing data, with invalid data etc. Add your test data to the
sql/mock_data.sql
file. - Write tests in the test folder. Possibly, add mock data in .json fixtures files. You can take a look at the existing tests: a lots of typical cases are already covered for some resources (create, delete, find, findall, count...).
✳️ The rights management is detailed in the Grottocenter's Rights Management.
-
git rebase -i
need to be used to group multiple "work in progress" commits into a single commit. -
git remote prune origin
to remove all branches in local that have been deleted on Github. -
When the feature is ready you need to create a
pull request
on Github (https://github.com/GrottoCenter/Grottocenter3/pulls) : Let base: develop and compare: the branch. -
Add a "Fix #1234" message with "1234" being the issue fixed by your PR in order to close it automatically when the PR is merged.
-
After the code review (which can include follow-up commits), the branch can be merged on develop with button "Merge pull request" ("Rebase and merge").
-
Don't forget to remove the remote branch after the merge