Skip to content

harfialpharaby/socialize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socialize

Pair Project Phase 1 by Samuel and Harfi

Hacktiv8 Pair Project as Final Project on phase 1 using expressjs, ejs, sequelize, herokuapp

Application

Accessing the web by using this link https://sosialisasi.herokuapp.com

Getting started

Run commands below :

git clone https://github.com/harfialpharaby/socialize.git
git checkout -b <new-feature-development>

Installation

Run the following commands :

npm init
sequelize db:create
sequelize db:migrate

Feeds Docs

Show add feed form

GET /feeds/add

data = req.session

Add feed

POST /feeds/add

req = {
    body: {
        title = <feed title>, 
        content = <feed content>,
        tagsName = <tags list no space with comma delimiter>
    }
}

Show edit feed form

GET /feeds/edit

data = {
    feed = <getting feed by req.params.id>, 
    fullName = req.session.fullName
}

Show tagged feed

GET /tagged/:tagName

req = {
    session: {
        fullName = STRING<logged in user>, 
        userId = INTEGER<logged in user>
    },
    params: {
        tagsName = ARRAY[STRING<searched tags>]
    }
}

Like feature

GET /like/:feedId

req = {
    session: userId,
    params: {
        feedId: INTEGER<feed id>
    }
}

Dislike feature

GET /dislike/:feedId

req = {
    session: userId,
    params: {
        feedId: INTEGER<feed id>
    }
}

User Docs

Register form

GET /users/register

Register

POST /users/register

req = {
    body: {
        {
            first_name: STRING<firstName>,
            last_name: STRING<lastName>,
            password: STRING<password>,
            email: STRING<email>,
            username: STRING<username>,
            profilPict: '161bbd1abc24d29e1abefd0f21ff90f8'
        }
    }
}

Show own profile

GET /user/page

req = {
    session: {
        userId: INTEGER<user id>,
        fullName: STRING<user full name>
    }
}

Show other profile

GET /otherpage/:id

req = {
    params: {
        id: INTEGER<other user id>
    },
    session: {
        fullName: STRING<logged in user full name>
    }
}

Show edit profile page

GET /users/edit

req = {
    session: {
        userId: INTEGER<logged in user id>,
        fullName: STRING<logged in user full name>
    },
    data: STRING<req.query success='success message' or failed='failed message'>
}

Edit profile page

POST /users/edit

req = {
    first_name: STRING<new first name>,
    last_name:STRING<new last name>,
    old_password: STRING<old password to indentify the user>,
    new_password: STRING<new password or null to unchange password>,
    email: STRING<new email>,
    username: STRING<new username>,
    session: {
        userId: INTEGER<logged in user id>
    }
}

Upload profile image

POST /users/profile

req = {
    file: {
        filename: STRING<new uploaded file image>
    },
    session: {
        userId: INTEGER<logged in user id>
    }
}

Tag Docs

Show tags list

GET /tags

req = {
    session: {
        fullName: STRING<logged in user full name>
    }
}

Middlewares

CheckIsUser

Validate logged in user to acessing other user page.

Usage :

const checkIsUser = require('../middlewares/checkIsUser')

How to use on every children path, example use on /otherpage parent path route ?

router.get('/otherpage',checkIsUser)
router.get('/otherpage/:id', UserController.otherPage)

checkLogin

Validate user is in login state so that user can access all logged in features.

Usage :

const checkLogin = require('../middlewares/checkLogin')

How to use on every children path, example use on /users parent path route ?

router.use('/',checkLogin)
router.get('/page', UserController.userPage)

redirectIfLogin

Usage :

const redirectIfLogin = require('../middlewares/redirectIfLogin')

How to use on every children path, example use on /users parent path route ?

router.get('/', redirectIfLogin)
router.get('/', UserController.loginPage)

Helpers

Hashingpassword

Usage

const hashingPassword = require('../helpers/hashingPassord')

How to use it ?

hashingPassword(
    STRING<random secret wether its auto generated or save on database for each data>, 
    STRING<plain password typed by user on browser>
)

About

Final Pair Project Phase 1 Hacktiv8

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 53.0%
  • HTML 44.4%
  • CSS 2.6%