Perishop is a web app that provides you with 300+ Shops.
แอพพลิเคชั่น Perishop ถูกสร้างขึ้นโดยใช้สแต็กค่าเฉลี่ย:
M: MongoDB (NoSQL / Non Relational database)
E: ExpressJs (Web application framework for building APIs)
A: Angular (Javascript MVC framework for front end web development)
N: NodeJs (Environment for running Javascript in the server side)
ไคลเอนต์-อ่าว/
Contains source code of the front end side :
- Components : client-perishop/src/app/components
- Services : client-perishop/src/app/services
- Modules : client-perishop/src/app
- Package.json (dependencies)
- Angular CLI generated files
ลูกค้า/
This is the folder you need to try the app, please don't delete it.
It contains the project build after running :
> ng build
เส้นทาง/
มีสองไฟล์:
- Shops.js :
Handling Shops end points.
- users.js :
Handling Users end points.
รุ่น/
- Shops.js :
Holds the definition of Shop Model using Mongoose Schema, for querying the database and handling all CRUD operations that concerns shops records.
- users.js :
Holds the definition of User Model using Mongoose Schema, for querying the database and handling all CRUD operations that deals with users records.
กำหนดค่า/
Holds an Object with database path to connect to using mongoose.
ฐานข้อมูล/
Holds the database folder where all records go and mongoDB journaling is saved.
- app.js
Is the entry point to the app. It holds a set of imports among which : Express, Mongoose, BodyParser, Passport and other middleware.
ฟีเจอร์ Perishop คือ:
สร้างโฟลเดอร์โครงการ (เช่น: PerishopApp) และ CD ลงในนั้น:
~$ cd ..../perishopApp
โคลนพื้นที่เก็บข้อมูล GitHub ในโฟลเดอร์โครงการของคุณโดยเรียกใช้:
~$ .../perishopApp // present working directory
git clone https://github.com/atidevs/perishop.git
คุณต้องติดตั้ง MongoDB: Community Server
https://www.mongodb.com/download-center?jmp=nav#community
หากคุณอยู่ใน MacOS หรือ Linux ข้ามขั้นตอนนี้หาก Windows ดาวน์โหลดและติดตั้ง Git:
https://git-scm.com/downloads
เมื่อติดตั้ง MongoDB และ Git ให้เปิด Git Bash และ CD ลงใน:
~$ cd .../mongodb/bin (... : wherever path you installed mongodb in, usually C:/mongodb/bin)
จากนั้นเรียกใช้คำสั่งนี้:
~$ mongod --dbpath=".../perishopApp/perishop/database"
เปิดเทอร์มินัล Git Bash อื่น:
~$ cd .../perishopApp/perishop (... : wherever the path to your perishopApp folder is)
จากนั้นเรียกใช้คำสั่งนี้:
~$ start
เปิดเบราว์เซอร์ของคุณแล้วไปที่:
localhost:3000
ยินดีด้วย! คุณอยู่ในหน้าแรก
หากคุณต้องการตรวจสอบระเบียนในฐานข้อมูลทำตามขั้นตอนเหล่านี้:
เปิดบรรทัดคำสั่ง (CMD) เป็นผู้ดูแลระบบใน Windows หรือ (เทอร์มินัล) ใน MacOS และ Linux และเรียกใช้:
> mongo
หลังจากนั้นถ้าคุณดูเทอร์มินัล Git Bash ที่คุณวิ่ง:
~$ mongod --dbpath=".../perishopApp/perishop/database"
คุณจะเห็นที่ไหนสักแห่งในตอนท้าย (เปิดการเชื่อมต่อ 2 ครั้ง): การเชื่อมต่อแรกมาจากแอพเอง (เมื่อคุณเรียกใช้ ~ $ start) และครั้งที่สองคือการที่เราเพิ่งเรียกใช้: (> Mongo)
ตอนนี้คุณสามารถเรียกใช้คำสั่งเหล่านี้:
> show dbs // to show all available databases
> use perishop // to use the perishop database displayed among available dbs
> show collections // to show all collections inside perishop db
> db.users.find().pretty() // to list all signed up users and their information
> db.shops.find().pretty() // to list all shops and their information
สนุก✌