https://gist.github.com/c4726b59d8a80d4e8bad419a48218d7b
https://gist.github.com/c6f950dc2f093f80eb33a011ebe35164
Create too the README.md, LICENCE & .gitignore.
In main file. e.g.: app.js
https://gist.github.com/201ded35b4c89db2b06433ca5559003b
https://gist.github.com/14fc45d5c75f3d1ba5d267e504008187
In this example, 3 entities will be used.
- Subscriptions.
- Promotions.
- Users.
Express documentation: https://expressjs.com/es/guide/routing.html
In main file. e.g.: app.js
https://gist.github.com/41b43826c2b4ca44f65507d1d0fe0c1e
Test some routes:
· http://localhost:5000/ · http://localhost:5000/subscriptions · http://localhost:5000/users · http://localhost:5000/sdfg
A ROUTER is an "entity". BREAD: Browse, Read, Edit, Add, Delete. If preparing the backend to consume as API with the frontend, static is not defined as entity.
In main file. e.g.: app.js
https://gist.github.com/cdbac3179be1d2cdc5d30f1a6e8ee1f9
In the router file. e.g.:subscriptionsRouter.js
Idem in the other routers entities. e.i.: staticRouter.js, promotionsRouter.js, usersRouter.js.
https://gist.github.com/bfdf856eecef09f93ce36a8de953ce76
7 paths if views are rendered. 5 routes if we prepare the backend to consume it via API: 1 BROWSE - See all 3 EDIT - Edit one (edit form) (only for views) 4 EDIT - Edit one 5 ADD - Add one (creation form) (only for views) 6 ADD - Add one 7 DELETE - Delete one 2 READ - See one
In the router file. e.g.:subscriptionsRouter.js
Idem in the other routers entities. e.i.: staticRouter.js, promotionsRouter.js, usersRouter.js.
https://gist.github.com/57a8dae6df24ad5c0ee18665639654e4
In the router file. e.g.:subscriptionsRouter.js
Idem in the other routers entities. e.i.: staticRouter.js, promotionsRouter.js, usersRouter.js.
https://gist.github.com/006a5eae261f9a353c053e833a146e61
In the router file. e.g.:subscriptionsControllers.js
Idem in the other routers entities. e.i.: staticRouter.js, promotionsRouter.js, usersRouter.js,
https://gist.github.com/ec7caf86123afe889b08c84081b77b3a
In this part of the process the control methods should show the results. The database is in charge of displaying the results.
-
[Edit the methods of the controller from the database.md](./Edit the methods of the controller from the database.md).
-
[Edit the methods of the controller using JSON files.md](./Edit the methods of the controller usin JSON files.md).
Another option is to send the views directly instead of the API, in this case with EJS as template engine.
- [MVC: Tell the controller to show the views](./MVC Tell the controller to show the views.md).
-
Configuration in the environment separate from code.
-
If you need to manage the sessions, e.g. Superadmin.
-
Create a session middleware.
-
Parse Cookie header.
In main file. e.g.: app.js
https://gist.github.com/e4380a90156b0578cd524f6c9549922d
In main file. e.g.: app.js
https://gist.github.com/bc986d387cae559a9fab450408fdb12e
Json Models lo utilizo porque como uso Json, saco los métodos más comunes afuera json Models I use it because as I use Json, I pull the most common methods outside
las rutas o controladores o sus métodos (no sé) ahora envian respuestas Json por que son APIs routes or controllers or their methods (I don't know) now send Json responses because they are APIs
<<<<<<< HEAD https://www.npmjs.com/package/cors
Extraigo las variables de desarrollo en archivos de producción .env y hago la documentación .env.example
requiero lainstalo la librería https://www.npmjs.com/package/dotenv
utilizo process.env para extraer las vaiables las pongo utilizo en app.js y ahora van a ser dínámicas
librería para el logueo social. http://www.passportjs.org/
Si hago pública la API. ver el tema de los token en la API (ver ejemplo en promotionsController) (el método serch se define desde el controlador, añadirlo en el lugar que va en el readme.md) Tengo que ver cuantas request pueden hacer por usuario.
Documentación https://medium.com/zero-equals-false/using-cors-in-express-cac7e29b005b e31ab6eab708556c3c99110afdac185d0a669e12