{"id":14957640,"url":"https://github.com/melardev/apiecomsequelizeexpress","last_synced_at":"2025-05-02T07:32:27.643Z","repository":{"id":38974774,"uuid":"170130957","full_name":"melardev/ApiEcomSequelizeExpress","owner":"melardev","description":"Ecommerce API app implemented with Express js and Sequelize","archived":false,"fork":false,"pushed_at":"2020-10-10T08:46:24.000Z","size":843,"stargazers_count":57,"open_issues_count":1,"forks_count":26,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-12T16:02:45.667Z","etag":null,"topics":["api","e-commerce","ecommerce","express","express-js","expressjs","full-stack","fullstack","node","node-js","nodejs","npm","orm","orm-framework","sequelize","sequelize-cli"],"latest_commit_sha":null,"homepage":"http://melardev.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/melardev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-11T13:13:08.000Z","updated_at":"2024-11-11T05:19:56.000Z","dependencies_parsed_at":"2022-08-09T07:01:24.653Z","dependency_job_id":null,"html_url":"https://github.com/melardev/ApiEcomSequelizeExpress","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melardev%2FApiEcomSequelizeExpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melardev%2FApiEcomSequelizeExpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melardev%2FApiEcomSequelizeExpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melardev%2FApiEcomSequelizeExpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/melardev","download_url":"https://codeload.github.com/melardev/ApiEcomSequelizeExpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224305847,"owners_count":17289446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","e-commerce","ecommerce","express","express-js","expressjs","full-stack","fullstack","node","node-js","nodejs","npm","orm","orm-framework","sequelize","sequelize-cli"],"created_at":"2024-09-24T13:15:16.790Z","updated_at":"2024-11-12T16:04:26.956Z","avatar_url":"https://github.com/melardev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bookshelf E-commerce Api\n# Table of Contents\n- [Introduction](#introduction)\n- [Full-stack Applications](#full-stack-applications)\n  * [E-commerce (shopping cart)](#e-commerce-shopping-cart)\n    + [Server side implementations](#server-side-implementations)\n    + [Client side implementations](#client-side-implementations)\n  * [Blog/CMS](#blogcms)\n    + [Server side implementations](#server-side-implementations-1)\n    + [Client side](#client-side)\n      - [The next come are](#the-next-come-are)\n  * [Simple CRUD(Create, Read, Update, Delete)](#simple-crudcreate-read-update-delete)\n    + [Server side implementations](#server-side-implementations-2)\n    + [Client side implementations](#client-side-implementations-1)\n      - [The next come are](#the-next-come-are-1)\n  * [CRUD + Pagination](#crud--pagination)\n    + [Server side implementations](#server-side-implementations-3)\n      - [The next come are](#the-next-come-are-2)\n    + [Client side implementations](#client-side-implementations-2)\n      - [The next come are](#the-next-come-are-3)\n- [Follow me](#social-media-links)\n    \n# Introduction\nThis is one of my E-commerce API app implementations. It is written in Node js, using Express and Sequelize ORM framework as the main dependencies.\nThis is not a finished project by any means, but it has a valid enough shape to be git cloned and studied if you are interested in this topic.\nIf you are interested in this project take a look at my other server API implementations I have made with:\n\n# Full-stack Applications\n## E-commerce (shopping cart)\n### Server side implementations\n- [Spring Boot + Spring Data Hibernate](https://github.com/melardev/SBootApiEcomMVCHibernate)\n- [Spring Boot + JAX-RS Jersey + Spring Data Hibernate](https://github.com/melardev/SpringBootEcommerceApiJersey)\n- [Node Js + Sequelize](https://github.com/melardev/ApiEcomSequelizeExpress)\n- [Node Js + Bookshelf](https://github.com/melardev/ApiEcomBookshelfExpress)\n- [Node Js + Mongoose](https://github.com/melardev/ApiEcomMongooseExpress)\n- [Python Django](https://github.com/melardev/DjangoRestShopApy)\n- [Flask](https://github.com/melardev/FlaskApiEcommerce)\n- [Golang go gonic](https://github.com/melardev/api_shop_gonic)\n- [Ruby on Rails](https://github.com/melardev/RailsApiEcommerce)\n- [AspNet Core](https://github.com/melardev/ApiAspCoreEcommerce)\n- [Laravel](https://github.com/melardev/ApiEcommerceLaravel)\n\nThe next to come are:\n- Spring Boot + Spring Data Hibernate + Kotlin\n- Spring Boot + Jax-RS Jersey + Hibernate + Kotlin\n- Spring Boot + mybatis\n- Spring Boot + mybatis + Kotlin\n- Asp.Net Web Api v2\n- Elixir\n- Golang + Beego\n- Golang + Iris\n- Golang + Echo\n- Golang + Mux\n- Golang + Revel\n- Golang + Kit\n- Flask + Flask-Restful\n- AspNetCore + NHibernate\n- AspNetCore + Dapper\n\n### Client side implementations\nThis client side E-commerce application is also implemented using other client side technologies:\n- [React Redux](https://github.com/melardev/ReactReduxEcommerceRestApi)\n- [React](https://github.com/melardev/ReactEcommerceRestApi)\n- [Vue](https://github.com/melardev/VueEcommerceRestApi)\n- [Vue + Vuex](https://github.com/melardev/VueVuexEcommerceRestApi)\n- [Angular](https://github.com/melardev/AngularEcommerceRestApi)\n\n## Blog/CMS\n### Server side implementations\n- [Spring Boot + Spring Data Hibernate](https://github.com/melardev/SpringBootApiBlog)\n- [Go + Gin Gonic](https://github.com/melardev/GoGonicBlogApi)\n- [NodeJs + Mongoose](https://github.com/melardev/ApiBlogExpressMongoose)\n- [Laravel](https://github.com/melardev/LaravelApiBlog)\n- [Ruby on Rails + JBuilder](https://github.com/melardev/RailsApiBlog)\n- [Django + Rest-Framework](https://github.com/melardev/DjangoApiBlog)\n- [Asp.Net Core](https://github.com/melardev/AspCoreApiBlog)\n- [Flask + Flask-SQLAlchemy](https://github.com/melardev/FlaskApiBlog)\n\nThe next to come are:\n- Spring Boot + Spring Data Hibernate + Kotlin\n- Spring Boot + Jax-RS Jersey + Hibernate + Kotlin\n- Spring Boot + mybatis\n- Spring Boot + mybatis + Kotlin\n- Asp.Net Web Api v2\n- Elixir\n- Golang + Beego\n- Golang + Iris\n- Golang + Echo\n- Golang + Mux\n- Golang + Revel\n- Golang + Kit\n- Flask + Flask-Restful\n- AspNetCore + NHibernate\n- AspNetCore + Dapper\n\n### Client side\n- [Vue + Vuex](https://github.com/melardev/VueVuexBlog)\n- [Vue](https://github.com/melardev/VueBlog)\n- [React + Redux](https://github.com/melardev/ReactReduxBlog)\n- [React](https://github.com/melardev/ReactBlog)\n- [Angular](https://github.com/melardev/AngularBlog)\n\nThe next come are\n- Angular NgRx-Store\n- Angular + Material\n- React + Material\n- React + Redux + Material\n- Vue + Material\n- Vue + Vuex + Material\n- Ember\n\n## Simple CRUD(Create, Read, Update, Delete)\n### Server side implementations\n- [Spring Boot + Spring Data Hibernate](https://github.com/melardev/SpringBootApiJpaCrud)\n- [Spring boot + Spring Data Reactive Mongo](https://github.com/melardev/SpringBootApiReactiveMongoCrud)\n- [Spring Boot + Spring Data Hibernate + Jersey](https://github.com/melardev/SpringBootApiJerseySpringDataCrud)\n- [NodeJs Express + Mongoose](https://github.com/melardev/ExpressMongooseApiCrud)\n- [Nodejs Express + Bookshelf](https://github.com/melardev/ExpressBookshelfApiCrud)\n- [Nodejs Express + Sequelize](https://github.com/melardev/ExpressSequelizeApiCrud)\n- [Go + Gin-Gonic + Gorm](https://github.com/melardev/GoGinGonicApiGormCrud)\n- [Ruby On Rails](https://github.com/melardev/RailsApiCrud)\n- [Ruby On Rails + JBuilder](https://github.com/melardev/RailsApiJBuilderCrud)\n- [Laravel](https://github.com/melardev/LaravelApiCrud)\n- [AspNet Core](https://github.com/melardev/AspNetCoreApiCrud)\n- [AspNet Web Api 2](https://github.com/melardev/AspNetWebApiCrud)\n- [Python + Flask](https://github.com/melardev/FlaskApiCrud)\n- [Python + Django](https://github.com/melardev/DjanogApiCrud)\n- [Python + Django + Rest Framework](https://github.com/melardev/DjangoRestFrameworkCrud)\n\n### Client side implementations\n- [VueJs](https://github.com/melardev/VueAsyncCrud)\n\n#### The next come are\n- Angular NgRx-Store\n- Angular + Material\n- React + Material\n- React + Redux + Material\n- Vue + Material\n- Vue + Vuex + Material\n- Ember\n- Vanilla javascript\n\n## CRUD + Pagination\n### Server side implementations\n- [Spring Boot + Spring Data + Jersey](https://github.com/melardev/SpringBootJerseyApiPaginatedCrud)\n- [Spring Boot + Spring Data](https://github.com/melardev/SpringBootApiJpaPaginatedCrud)\n- [Spring Boot Reactive + Spring Data Reactive](https://github.com/melardev/ApiCrudReactiveMongo)\n- [Go with Gin Gonic](https://github.com/melardev/GoGinGonicApiPaginatedCrud)\n- [Laravel](https://github.com/melardev/LaravelApiPaginatedCrud)\n- [Rails + JBuilder](https://github.com/melardev/RailsJBuilderApiPaginatedCrud)\n- [Rails](https://github.com/melardev/RailsApiPaginatedCrud)\n- [NodeJs Express + Sequelize](https://github.com/melardev/ExpressSequelizeApiPaginatedCrud)\n- [NodeJs Express + Bookshelf](https://github.com/melardev/ExpressBookshelfApiPaginatedCrud)\n- [NodeJs Express + Mongoose](https://github.com/melardev/ExpressApiMongoosePaginatedCrud)\n- [Python Django](https://github.com/melardev/DjangoApiCrudPaginated)\n- [Python Django + Rest Framework](https://github.com/melardev/DjangoRestFrameworkPaginatedCrud)\n- [Python Flask](https://github.com/melardev/FlaskApiPaginatedCrud)\n- [AspNet Core](https://github.com/melardev/AspNetCoreApiPaginatedCrud)\n- [AspNet Web Api 2](https://github.com/melardev/WebApiPaginatedAsyncCrud)\n\n#### The next come are\n- NodeJs Express + Knex\n- Flask + Flask-Restful\n- Laravel + Fractal\n- Laravel + ApiResources\n- Go with Mux\n- AspNet Web Api 2\n- Jersey\n- Elixir\n\n### Client side implementations\n- [Angular](https://github.com/melardev/AngularPaginatedAsyncCrud)\n- [React-Redux](https://github.com/melardev/ReactReduxPaginatedAsyncCrud)\n- [React](https://github.com/melardev/ReactAsyncPaginatedCrud)\n- [Vue + Vuex](https://github.com/melardev/VueVuexPaginatedAsyncCrud)\n- [Vue](https://github.com/melardev/VuePaginatedAsyncCrud)\n\n\n#### The next come are\n- Angular NgRx-Store\n- Angular + Material\n- React + Material\n- React + Redux + Material\n- Vue + Material\n- Vue + Vuex + Material\n- Ember\n- Vanilla javascript\n\n# Social media links\n- [Youtube Channel](https://youtube.com/melardev) I publish videos mainly on programming\n- [Blog](http://melardev.com) Sometimes I publish the source code there before Github\n- [Twitter](https://twitter.com/@melardev) I share tips on programming\n\n\n## WARNING\nI have mass of projects to deal with so I make some copy/paste around, if something I say is missing or is wrong, then I apologize\nand you may let me know opening an issue.\n\n# Get started\n1. Install dependencies\n`npm install`\n2. Rename the .env.example to .env and setup database, according to your needs\nThe database settings can be changed from the .env file, you can switch between sqlite and MySQL effortlessly by \nonly changing the dialect and the username/password for your MySQL server if you are using MySQL.\nI strongly encourage you to use MySQL because using SQLite you may run into \" sqlite database locked\" issues.\nif you use sqlite(default) then:\n`node_modules\\.bin\\sequelize db:migrate`\nif mysql or other then:\n`node_modules\\.bin\\sequelize db:drop \u0026\u0026 node_modules\\.bin\\sequelize db:create \u0026\u0026 node_modules\\.bin\\sequelize db:migrate`\n3. Seed database\n`node_modules\\.bin\\sequelize db:seed:all`\nPlease notice that regarding the seeding implementation I am not doing it the _sequelize_ way\nbecause I do not use the sequelize param provided y the up function, instead I use mine.\n\n4. The last step is up to you, you can either open it in an IDE and debug it, or you can open the api.postman_collection.json with Postman, and then execute the queries\n\n# Features\n- Authentication / Authorization\n- Paging\n- CRUD operations on products, comments, tags, categories\n![Fetching products page](./github_images/postman.png)\n- Orders, guest users may place an order\n![Database diagram](./github_images/db_structure.png)\n\n# What you will learn\n- Sequelize ORM\n    - associations: hasMany, belongsTo, belongsToMany\n    - scopes\n    - virtuals\n    - complex queries\n    - paging\n    - eager loading, select columns on related associations\n    \n- express\n    - middlewares\n    - authentication\n    - authorization\n- seed data with faker js\n- misc\n    - project structure\n    - dotenv\n    \n# Understanding the project\nThe project is meant to be educational, to learn something beyond the hello world thing we find in a lot, lot of \ntutorials and blog posts. Since its main goal is educational, I try to make as much use as features of APIs, in other\nwords, I used different code to do the same thing over and over, there is some repeated code but I tried to be as unique\nas possible so you can learn different ways of achieving the same goal.\nProject structure:\n- models: Mvc, it is our domain data.\n- dtos: it contains our serializers, they will create the response to be sent as json. They also take care of validating the input(feature incomplete)\n- controllers: well this is the mvC, our business logic.\n- routes: they register routes to router middleware\n- middleware: some useful middleware, mainly the authentication and authorization middleware.\n- config: the database configurer.\n- seeders: contains the file that seeds the database.\n- .env the env file from where to populate the process.env node js environment variable\n- public: contains the uploaded files.\n\n# Useful Sequelize CLI commands\nReplace backslashes by forward slashes if you are in Linux or Mac\n\n- Create database\n`node_modules\\.bin\\sequelize db:create`\n- Drop database\n`node_modules\\.bin\\sequelize db:drop`\n- Run migration files\n`node_modules\\.bin\\sequelize db:migrate`\n\n- Seed all\n`node_modules\\.bin\\sequelize db:seed:all`\n- Undo only last seed\n`node_modules\\.bin\\sequelize db:seed:undo`\n- Undo all\n`node_modules\\.bin\\sequelize db:seed:undo:all`\n\n- Drop, Create and migrate\n`reset.bat`\n- Drop And migrate\n`drop_migrate.bat`\n\n# Steps followed to create this project (incomplete)\n\n```shell\nnpm install --save sequelize\n# npm install --save sqlite3\nnpm install --save mysql2\n# or\n# yarn add sqlite3\n# yarn add mysql2\nnpm install --save sequelize-cli\n# Generate sequelize folders and config.json with:\n./node_modules/.bin/sequelize init\n\n# Populate config.json with connection settings\n# then create the database with:\n$ ./node_modules/.bin/sequelize db:create\n\n# generate models and migration files\n$ node_modules/.bin/sequelize model:generate --name User --attributes firstName:string,lastName:string,email:string\n\n# write migration code\n\n# migrate\n$ node_modules/.bin/sequelize db:migrate\n\n# generate seeds\n$ .\\node_modules\\.bin\\sequelize seed:generate --name seed-categories\n\n# seed\n$ node_modules/.bin/sequelize db:seed:all\n```\n\n# TODO\n- Hook user pre create, save ROLE_USER\n- Timestamped Model\n- I have troubles setting column names with underscores(i.e userId), this is why I named the foreign key columns with camelcase(userId, orderId)\nand not underscore, in the future I have to refactor to snake case instead\n- Unit testing\n- Improve README.md\n\n# Resources\n- [Sequelize](http://docs.sequelizejs.com/)\n- [Sequelize Scopes](http://docs.sequelizejs.com/manual/tutorial/scopes.html)\n- [Express](https://expressjs.com/)\n- [Express-jwt](https://github.com/auth0/express-jwt)\n- [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken)\n- [Required attribute](https://stackoverflow.com/questions/52063685/sequelize-eager-loading-associations-with-optional-scopes)\n- [sanitize-html](https://www.npmjs.com/package/sanitize-html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelardev%2Fapiecomsequelizeexpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelardev%2Fapiecomsequelizeexpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelardev%2Fapiecomsequelizeexpress/lists"}