https://github.com/leoelicos/submitted
Wordpress-style Tech Blog
https://github.com/leoelicos/submitted
expressjs handlebarsjs mvc-pattern nodejs sequelizejs
Last synced: 5 days ago
JSON representation
Wordpress-style Tech Blog
- Host: GitHub
- URL: https://github.com/leoelicos/submitted
- Owner: leoelicos
- License: mit
- Created: 2022-05-24T12:43:45.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-17T00:56:23.000Z (over 2 years ago)
- Last Synced: 2025-07-06T08:05:12.515Z (8 months ago)
- Topics: expressjs, handlebarsjs, mvc-pattern, nodejs, sequelizejs
- Language: JavaScript
- Homepage: https://leoelicos-tech-blog.herokuapp.com/
- Size: 341 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# submitted!
   
---
## why
Read and create blogs.
This application uses npm packages `express`, `express-handlebars`, `express-session`, `sequelize`, `connection-session-sequelize`, `bcrypt`, `mysql2` and `dotenv`.
CRUD API calls are also defined for back end development allow a developer to test requests using Insomnia to prepare for front-end integration in the future.
As defined in [Issues](https://github.com/leoelicos/submitted/issues), my future direction for submitted includes options to create Categories and Tags on the front end, as well as select them while creating a Blog. Currently they can only be created from the back end.
I made this application to learn about full-stack applications created with Model-View-Controller, and I used GitHub Projects and various Pull Requests to create this app: https://github.com/leoelicos/submitted/projects/1
## Table of Contents
- [Usage](#usage)
- [Screenshots](#screenshots)
- [Installation for API testing in Insomnia](#installation-for-api-testing-in-insomnia)
- [Example of API response](#example-of-api-response)
- [Credits](#credits)
- [License](#license)
## Usage
Visit [submitted](https://leoelicos-tech-blog.herokuapp.com/) on a browser on a computer or mobile.
### Video Demo:
https://user-images.githubusercontent.com/99461390/171432484-b0d20930-92b8-4f02-bcb3-d773507a1ed9.mp4
Video is also on YouTube: https://youtu.be/E2-GN5ZVDKY
## Screenshots
### Screenshot: submitted Homepage

### Screenshot: submitted Dashboard

### Screenshot: submitted Login

## Installation for API testing in Insomnia
### 0. Required
| Programs | Download links |
| ---------- | ------------------------------------------ |
| `Node` | https://nodejs.org/en/download/ |
| `Mysql` | https://dev.mysql.com/downloads/installer/ |
| `Insomnia` | https://insomnia.rest/download |
### 1. Git clone and go inside
```sh
git clone https://github.com/leoelicos/submitted.git
cd submitted
```
### 2. Rename `.env.EXAMPLE` to `.env`
```sh
mv .env.Example .env
```
Input your Mysql credentials. _Don't forget to save!_
- `DB_USER={username}`
- `DB_PASSWORD={password}`
### 3. Go inside `db`, invoke `Mysql`, enter {password}, run `schema`
```sh
cd db
mysql -u root -p
{password}
source schema.sql;
exit
```
### 4. Return to root, install dependencies, (optionally) run seed
```sh
cd ..
npm install
npm run seed
```
### 5. Start the server, then access the API with Insomnia
```sh
npm start
```
## API
### Base URL
All URLs start with `http://localhost:3001/api/`.
No API key is required. You will need to either log in, or sign up and be logged in, in order to receive the responses.
---
### Searching
GET request to `/{type}` searches for items which have a specified type.
Possible types include:
- blogs: `blog`
- categories: `category`
- tags: `tag`
- blog-tags links: `blogtag`
- comments: `comment`
- users: `user`
**Example**:
```sh
GET http://localhost:3001/api/blog
```
---
### Requesting a specific item
GET request to `/{type}/{id}` searches for items which have a specified type and specified id.
Possible types include:
- a blog: `blog`
- a blog category: `category`
- a tag: `tag`
- a blog-tag link: `blogtag`
- a comment: `comment`
- a user: `user`
**Example**:
```sh
GET http://localhost:3001/api/blog/1
```
---
### Adding a specific item
POST request to `/{type}/` adds an item of the specified type. You need to include a JSON with a valid body.
Possible types and the JSON body:
| `{type}` | JSON |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| `blog` | `{ "title": STRING, "user_id": INTEGER, "category_id": INTEGER, "summary": STRING, "text": STRING }` |
| `blogtag` | `{ "blog_id": INTEGER, "tag_id": INTEGER }` |
| `category` | `{ "category_name": STRING }` |
| `comment` | `{ "text": STRING, "user_id": INTEGER, "blog_id": INTEGER }` |
| `tag` | `{ "tag_name": STRING }` |
| `user` | `{ "username": STRING, "password": STRING }` |
**Example**
```sh
POST http://localhost:3001/api/tags/
{ "tag_name": "Express" }
```
---
### Editing a specific item
PUT request to `/{type}/{id}` edits an item of the specified type. You need to include a JSON with a valid body.
Possible types and the JSON body:
| `{type}` | JSON |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| `blog` | `{ "title": STRING, "user_id": INTEGER, "category_id": INTEGER, "summary": STRING, "text": STRING }` |
| `blogtag` | `{ "blog_id": INTEGER, "tag_id": INTEGER }` |
| `category` | `{ "category_name": STRING }` |
| `comment` | `{ "text": STRING, "user_id": INTEGER, "blog_id": INTEGER }` |
| `tag` | `{ "tag_name": STRING }` |
| `user` | `{ "username": STRING, "password": STRING }` |
**Example**
```sh
PUT http://localhost:3001/api/comment/1
{ "text": "Good advice!", "user_id": 2, "blog_id": 1 }
```
---
### Deleting a specific item
DELETE request to `/{type}/{id}` deletes items which have a specified type and specified id.
Possible types include:
- a blog: `blog`
- a blog category: `category`
- a tag: `tag`
- a blog-tag link: `blogtag`
- a comment: `comment`
- a user: `user`
**Example**:
```sh
DELETE http://localhost:3001/api/category/1
```
---
## Example of API response
Request:
```sh
GET http://localhost:3001/api/category
```
Response:
```json
[
{
"id": 1,
"category_name": "Homework"
},
{
"id": 2,
"category_name": "Challenges"
},
{
"id": 3,
"category_name": "Projects"
},
{
"id": 4,
"category_name": "Mini-projects"
}
]
```
## Credits
- BCS Resources
- [Normalize.css](https://necolas.github.io)
## License
© Leo Wong
Licensed under the [MIT License](./LICENSE).