This is an exercise as part of the Generación-K learning process. It consist in a fullstack app. The API REST has been build with node / mongoDB / express and the client with Vue and Vuetify.
It has been tested with Jest and SUPERTEST (unitary) and CYPRESS (e2e)
- use
npm run test
(back) - use Cypress
npx cypress open
(client)
- You need to
npm install
in both backend and client folders.
Blog-APIrest-practice
│
├── backend
│ └── src
│ ├── controller
│ │ ├── comments
│ │ ├── login
│ │ ├── offensivewords
│ │ ├── posts
│ │ ├── users
│ │ └── index.js
│ │
│ ├── repository
│ ├── test
│ ├── utils
│ ├── validator
│ ├── app.js
│ └── server.js
├── client
│ ├── public
│ ├── src
│ │ ├── assets
│ │ ├── components
│ │ │ ├── CardComment.vue
│ │ │ ├── CardFilter.vue
│ │ │ ├── CardOffensiveWords.vue
│ │ │ ├── CardPost.vue
│ │ │ ├── MountEdit.vue
│ │ │ ├── MountHome.vue
│ │ │ ├── MountNewPost.vue
│ │ │ ├── MountOffensiveWords.vue
│ │ │ ├── MountRead.vue
│ │ │ ├── TheContainerCreate.vue
│ │ │ ├── TheFooter.vue
│ │ │ ├── TheHeader.vue
│ │ │ ├── TheMainAdminPanel.vue
│ │ │ ├── TheMainFeed.vue
│ │ │ ├── TheMainLogin.vue
│ │ │ ├── TheMainRead.vue
│ │ │ └── TheMainSignup.vue
│ │ ├── data
│ │ ├── plugins
│ │ ├── router
│ │ ├── service
│ │ └── app.js
│ │
│ └── test
│
└── README.md
-
To launch server go to
backend/src
and typenode app.js
-
Find this file:
backend/ REST API Blog collection postman.json
and load it into your POSTMAN'S. It can be very helpful to play with the app and the different endpoints REST.
-
Posts and comments
-
GET all the posts (without comments) '/post'
-
POST a new post (without comments) '/post/'
-
PUT to modify an existent post (except from its comments) '/post/:id/'
-
GET one post (with comments) '/post/:id'
-
DELETE an existing post (with all its comments) '/post/:id/'
-
POST a new comment to a post '/post/:id/comments/'
-
PUT to modify an existent comment '/post/:id/comments/:id'
-
DELETE an existent comment from a specific post '/post/:id/comments/:id'
-
-
Offensive Words /offensivewords
- POST ,/offensivewords
- GET all,/offensivewords
- GET one, /offensivewords/:id
- DELETE ONE , /offensivewords/:id
- PUT, /offensivewords/:id
There is an array of Offensive Words that only can be access by admin users . If a new comment contains any of this words, the app will throw an error specifying which words must be ommited to have a succesful comment.
There are two types of authenticated users: "admin" and "publisher". Authentication has been implemented with BASIC AUTH + JWT token
- Admin has permission to add edit and delete whatever she/he wants
- Publisher only can add comments and posts and edit or delete the items who's author is herself/himself.
- These two types and everyone else can read all the information but cannot add delete or modify info.
- Anyone can Sign Up. Publisher rol will be assigned to this person.
- When the app launch if there are no users, some default users will be upload.
La aplicación está en, al menos, 4 módulos Node:
- app.js: Tendrá el servidor Express.
- controller.js: Tendrá definidos los métodos de la API REST. Se usará un router que será configurado en Express.
- repository.js: Módulo que contendrá el código de acceso a la base de datos.
- validator.js: Validador que verifica que el comentario no contiene ninguna palabra ofensiva.
This is a Vue + vuetify project. The image filters and upload image function has been based on the Vue Vixens practice that you can find in this repo: https://github.com/VueVixensESP/vuevixens-instagram
npm install
npm run serve
npm run build
npm run lint
npx cypress open