Skip to content

iCheater/expressServer

Repository files navigation

What is this:

This is e-commerce project (online store)

We learn how to make an online store. During creation, we encountered a problem: Github is full of “helloworld” level tutorials, there are no examples of PRODUCTION READY, a well-designed application on which you can understand how to make your application better. We want to make an application using the current best practices and share it with community. We will accept any help with joy.

We use trello as task tool (right now it has tasks only on Russian but we can start using english only)

Current technological stack:
  • express
  • sequelize
  • redis
  • nunjucks
Roadmap:
Phase 1
  • Fully working MVP of store
Phase 2
  • split project into "frontend server and api server"
  • split "frontend server" and "administration section"(CRM\CMS) and rewrite it with vue.js
Phase 3
  • add vue and SSR to frontend server
  • performance optimizations

We adhere to the JSON.API standard, but, you know...

Current features:
  • session based cart, cart calculator
  • mailing for new users, order and so on
  • multi auth with passport.js

How to run:

example: login\password: shop_server\shop_server_db

foo@bar:~$ sudo apt update
foo@bar:~$ sudo apt install postgresql postgresql-contrib
foo@bar:~$ sudo -u postgres createuser --interactive // type shop_server
Enter name of role to add: shop_server
Shall the new role be a superuser? (y/n) y
foo@bar:~$ sudo -u postgres createdb shop_server_db // creating db
foo@bar:~$ sudo adduser shop_server //create linux user with password shop_server 
Добавляется пользователь «shop_server» ...
Добавляется новая группа «shop_server» (1001) ...
Добавляется новый пользователь «shop_server» (1001) в группу «shop_server» ...
Создаётся домашний каталог «/home/shop_server» ...
Копирование файлов из «/etc/skel» ...
Новый пароль : 
Повторите ввод нового пароля : 
passwd: пароль успешно обновлён
Изменение информации о пользователе shop_server
Введите новое значение или нажмите ENTER для выбора значения по умолчанию
        Полное имя []: 
        Номер комнаты []: 
        Рабочий телефон []: 
        Домашний телефон []: 
        Другое []: 
Данная информация корректна? [Y/n] y
foo@bar:~$ sudo -u shop_server psql shop_server_db // enter in postgress console
psql (12.1 (Ubuntu 12.1-1.pgdg19.04+1), server 11.6 (Ubuntu 11.6-1.pgdg19.04+1))
Type "help" for help.
shop_server_db=# 

in postgress console:

shop_server_db=# \password shop_server (change password to "shop_server")

3. Install Redis

foo@bar:~$  sudo apt-get install redis-server
foo@bar:~$  sudo systemctl enable redis-server.service
foo@bar:~$  sudo snap install redis-desktop-manager

Linux Mint users have to add export PATH=$PATH:/snap/bin into .bashrc if you dont have icons in apps menu:

foo@bar:~$  sudo ln -s /var/lib/snapd/desktop/applications/ /usr/share/applications/snap (if you dont get icons in search menu)

4. Install NVM

foo@bar:~$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

After NVM installation complete tell NVM to install current version:

foo@bar:~$  nvm install node

or install latest version:

foo@bar:~$  nvm install --lts

you can change default node version

foo@bar:~$  nvm alias default

5. Install npm dependencies

Install dependencies from package.json

foo@bar:~$  npm install

or

Install dependencies from package-lock.json

foo@bar:~$  npm ci

6. Install Gulp

foo@bar:~$  npm install --global gulp
npm rebuild node-sass --force

7. Run Gulp!

foo@bar:~$ gulp

Oops! Fill db with mockup data

foo@bar:~$ npm run seed

Things to discuss:

maybe switch sequelize to objection.js

Usefull

G++
sudo apt-get install build-essential

node-express-sequelize-postgresql-association GIST

find process and kill it

foo@bar:~$  sudo netstat -nlp | grep :3000
foo@bar:~$  kill -9 process_id
foo@bar:~$  fuser -k 3000/tcp

https://www.tutorialspoint.com/expressjs/expressjs_restful_apis.htm

One day we will use full power of migrations https://gist.github.com/vapurrmaid/a111bf3fc0224751cb2f76532aac2465

npx sequelize-cli migration:generate --name [modelname]
npx sequelize-cli seed:generate --name users
npx sequelize-cli seed:create --name my-seed-file

npx sequelize-cli db:seed:all
npx sequelize-cli db:seed:undo:all
npx sequelize-cli db:seed:undo --seed name-of-seed-as-in-data
npx sequelize-cli db:seed --seed 20191011121208-update-feature.js

Nice advanced seeding https://medium.com/@edtimmer/sequelize-associations-basics-bde90c0deeaa

About

e-commerce project (online shop)

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •