Skip to content

seanedw1/URL-Shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL-Shortener

codeship status for seanedw1/URL-Shortener

simplified URL shortener application

Table of contents

Package dependencies

Install all dependencies.

npm install

npm install -g mocha gulp

ENV

create a env.json on root level for database connection

{
  "DB_NAME": "dbname",
  "DB_USER": "dbuser",
  "DB_PASS": "dbpass",
  "DB_HOST": "localhost",
  "DB_SCHEMA": "mysql",
  "DB_PORT": "3306"
}

Server

start the server

node src/server

Unit Testing

To run unit test.

*sever must be off

mocha

or

npm test

Gulp

gulp is used to automate a github commit so first it adds all file changes followed by a commit message then a push to origin master. to use this automated feature in terminal use

gulp

This project uses gulp for automated package.json version bump

// bump up major
gulp bump --major

// bump up minor
gulp bump --minor

// bump up minor
gulp bump --patch

Virtual private server

API on virtual private server youtube

Workflow

1 Create a new feature branch

git checkout -b branchname

2 Push up to new feature branch

git add -A
git commit -m 'insert your msg here'
git push

if this is your first time pushing to a new remote branch run

git push --set-upstream origin branchname

3 Once commited we return to the master branch to merge (pull in) the feature branch

git checkout master

4 Now in the master branch merge your feature branch into your master branch using the merge command followed by a push

git merge branchname
git push

5 Now that we have successfully merged our feature branch our ci tool(codeship) will check to make sure our codebase is passing.

6 Once codeship confirms that the build passes we want to tag this version then merge our master into our release branch.

7 Create a tag run

git tag v1.0.6 commitidgoeshere

8 Once we have created our tag we want to continue with our merge to the release branch

git checkout release
git merge master
git push

9 Once we push to release branch our codebase enters the first phase of the Deployment pipeline

Deployment

  1. First we merge our codebase to master our ci test runs to confirm our codebase is passing our automated unit test.

  2. If our codebase passes ci test (codeship) we manually merge master branch to the release branch which is the first step in the deployment pipeline.

  3. When ci tool (codeship) confirms the build is good it will automatically be deployed from release repo onto our staging server.

  4. once completed and we confirmed out codebase is good we will manually push from staging server to production server.

Endpoints

Index

Status

crud for urls

crud for users

Index

GET / - index hello world
{
  "hello": "world"
}
Status

GET /status - api status

{
  "healty": true
}

URL

POST /api/v1/urls - Create shortened link

  • when creating new urls include http://
{
  "url": "http://www.facebook.com/"
}

GET /go/:shortURL - redirect based upon the short URL provided

{}

GET /api/v1/urls - get urls

[
  {
    "id": 1,
    "url": "www.facebook.com",
    "shortURL": "8q6rdltjrl",
    "updatedAt": "2016-10-04T22:07:39.000Z",
    "createdAt": "2016-10-04T22:07:39.000Z"
  },
  {
    "id": 2,
    "url": "http://www.testurl1.com",
    "shortURL": "66vo7fl7aq8",
    "createdAt": "2016-10-02T22:19:27.000Z",
    "updatedAt": "2016-10-02T22:19:27.000Z",
    "userID": null
  },
  {
    "id": 3,
    "url": "http://www.exampleurl2.com",
    "shortURL": "66vo7fliar8",
    "createdAt": "2016-10-02T22:19:27.000Z",
    "updatedAt": "2016-10-02T22:19:27.000Z",
    "userID": null
  }
]

GET /api/v1/urls/:id - get url by id

{
  "id": 1,
  "url": "http://www.exampleurl.com",
  "shortURL": "66vo7fl7ar8",
  "createdAt": "2016-10-02T22:19:27.000Z",
  "updatedAt": "2016-10-02T22:19:27.000Z",
  "userID": null
}

POST /api/v1/urls/:id - update url

  "url": "http://www.example.com",
  "shortURL": "66vo7fl7ar8"

DELETE /api/v1/urls/:id - delete url

1

Users

POST /api/v1/users - Create user

{
	"name": "bart",
	"username": "simpsonsfan",
	"password": "testpass"
}

GET /api/v1/users - get users

[
  {
    "id": 1,
    "name": "david",
    "username": "david12",
    "password": "reojgoifdklm",
    "createdAt": "2016-10-08T01:45:31.000Z",
    "updatedAt": "2016-10-08T01:45:31.000Z",
    "urls": []
  },
  {
    "id": 2,
    "name": "peter",
    "username": "peterpanman",
    "password": "reojgoifdklm",
    "createdAt": "2016-10-08T01:45:31.000Z",
    "updatedAt": "2016-10-08T01:45:31.000Z",
    "urls": []
  },
  {
    "id": 3,
    "name": "dan",
    "username": "dantheman",
    "password": "reojgoifdklm",
    "createdAt": "2016-10-08T01:45:31.000Z",
    "updatedAt": "2016-10-08T01:45:31.000Z",
    "urls": []
  }
]

GET /api/v1/users/:id - get user by id

{
  "id": 3,
  "name": "dan",
  "username": "dantheman",
  "password": "reojgoifdklm",
  "tokenreq": "true",
  "createdAt": "2016-10-08T01:45:31.000Z",
  "updatedAt": "2016-10-08T01:45:31.000Z",
  "urls": []
}

POST /api/v1/users/:id - update user

{
  "name": "bart",
  "username": "simpsonsfan"
}

DELETE /api/v1/users/:id - delete user

1
Contributors

View Contributors

Style Guide reference

Airbnb