Skip to content
No description, website, or topics provided.
PLpgSQL JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
migrations
seeds
src
.gitignore
Procfile
README.md
knexfile.js
package-lock.json
package.json
postgrator-config.js
postgrator-production-config.js

README.md

Bedtime-server

Express app for bedtime-client

postgresql knexjs nodejs expressjs

The app is a a platform where users can read kids stories and publish their owns.

Teach Stack

  • React
  • Node
  • Express
  • PostgreSQl
  • Knex
  • JWT
  • BcryptJS
  • Mocha
  • Chai
  • Supertest
  • Enzyme

Data Models

Story Schema

  author TEXT NOT NULL,
  name TEXT NOT NULL,
  description TEXT NOT NULL,
  content TEXT NOT NULL,
  date_revised TIMESTAMP,
  rating DECIMAL DEFAULT 0.00,
  cover INTEGER REFERENCES images(id),
  status BOOLEAN DEFAULT false NOT NULL

User Schema

  user_name TEXT NOT NULL,
  password TEXT NOT NULL,
  email TEXT,
  first_name TEXT,
  last_name TEXT,
  avatar TEXT,
  created_at TIMESTAMP DEFAULT now()

API ENDPOINTS

All requests and responses are in JSON format.

Action Path
Authentication https://bedtime-server.herokuapp.com/api/auth
Users https://bedtime-server.herokuapp.com/api/auth
Stories https://bedtime-server.herokuapp.com/api/stories
Image upload https://bedtime-server.herokuapp.com/api/uploads

Authentication

POST to /login endpoint for creation of JWT. It accepts the following request body,

{ user_name, password }

This endpoint takes in the username and verifies the password. When validated, the server will respond with a token,

{ authToken }

Users

POST to *users/create endpoint for a new user creation. It accepts the following req.body,

{
  user_name, // 4-20 charachters
  password, // 8-20 chars, at least 1 number
  first_name,
  last_name,
}

Stories

GET to /stories retruns a list of stories that has status: true (stories that are reviewed by admin), without content property.

GET to /stories/:id returns a story object with content (html elements). Authorization is required.

Image upload

POST to /upload for an image upload. Accepts image file within from data. Returns:

{ id, link }

Setting up

Client

git clone https://github.com/olegakan/bedtime-client.git
npm install
npm test
npm start

Server

git clone https://github.com/olegakan/bedtime-server.git
npm install
npm test
npm run dev

Scripts

Start the application npm start

Start nodemon for the application npm run dev

Run the tests npm test

Migrate database npm run migrate

Seed db psql /DB_NAME/ < ./seeds/seed.tables.sql

Issues

Looking to contribute? Pick an issue from the issues tab.

Feature Requests

Please file an issue to suggest new features. Vote by adding 👍 on feature request to help us prioritize what to work on.

You can’t perform that action at this time.