Skip to content

dan3143/api-twitter

 
 

Repository files navigation

API Rest :: Twitter :: 2021

Academic purpose

Prerequisites

Clone the repo

> git clone https://github.com/jestrade/api-twitter.git

Enter to folder project

> cd api-twitter

Install the app

> npm i

Create .env file

  • Configuration Example:
    • HTTP_HOST -> IP of server, default is 127.0.0.1.
    • HTTP_PORT -> Node listening port, default is 3000.
    • LOG_ACCESS -> Path where the logs will be stored, don't specify the path, just the file name, default access.log.
    • JWTKEY -> Is used by JWT to sign the token.
    • APIWEATHERKEY -> Is used to consume the API.
    • DB_CONNECTION_STRING -> Connection string to connect mongodb database
    • SALT_ROUNDS -> Controls how much time is needed to calculate a single BCrypt hash, default is 10.
    • MAILER_HOST -> xx
    • MAILER_PORT -> xx
    • MAILER_USER -> xx
    • MAILER_PASSWORD -> xx
    • MAIL_FROM -> xx
    • TWITTER_CONSUMER_KEY -> xx
    • TWITTER_CONSUMER_SECRET -> xx
    • TWITTER_TOKEN_KEY -> xx
    • TWITTER_TOKEN_SECRET -> xx

Example connection string local, more info. MongoDB.

mongodb://username:password@host:port/database

Example connection string in cloud, more info MondoDB Atlas.

mongodb+srv://<username>:<password>@cluster0.rwp0b.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Rename .env.example to .env, and set parameters required, please dont include env:.

env:

# This is parameters required.
HTTP_HOST=
HTTP_PORT=
LOG_ACCESS=
JWTKEY=
APIWEATHERKEY=
DB_CONNECTION_STRING=
SALT_ROUNDS=
MAILER_HOST=
MAILER_PORT=
MAILER_USER=
MAILER_PASSWORD=
MAIL_FROM=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=
TWITTER_TOKEN_KEY=
TWITTER_TOKEN_SECRET=

Install nodemon as development dependency

> npm i --save-dev nodemon

Run the seeds

> npm run seeds

Run the app

Without nodemon

Run project without nodemon

> npm start

With nodemon

Run project with nodemon

> npm run dev

Run tests

> npm run test

Access points

domain/api/*

Authenticacion

´´´ headers: { x-access-token: "" } ´´´

API

Methods
URL GET POST PUT DELETE
/ error error error error
/users List all users

private - Authentication

Create user

body:

{

name,

email,

username,

password

passwordConfirmation

}

public

error Delete user

body:

{

id

}

private: - Authentication \ - Authorization

/users/:id Display user information: id

public

error Update user: id

{

name,

email,

password

}

private: - Authentication \ - Authorization

error
/users/login error Authenticate user

{

username,

password

}

public

error error
/tweets List all tweets

private - Authentication

Create tweet

body:

{

content

}

private

error Delete tweet

body:

{

tweetId

}

private: - Authentication \ - Authorization

/tweets/:id List tweet info and comments

public

error error error
/tweets/comments error Create tweet

body:

{

comment,

tweetId,

}

private

error Delete tweet

body:

{

tweetId,

commentId

}

private: - Authentication \ - Authorization

/tweets/likes error error Create tweet

body:

{

like(1|0),

tweetId,

}

1: like

0: unlike

private

error
/tweets/comments/:id error error
/tweets/external/:username Get tweets from real Twitter error error
/weather/:city Get weather from city

public

error error error
/tasks List all tasks

public

Create task

body:

{

content

}

public

error Delete task

body:

{

id

}

public

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 99.7%
  • Shell 0.3%