Skip to content

Installation & Setup

Vaishakh GK edited this page May 2, 2023 · 6 revisions

Installation

  1. Install Go programming language from here
  2. Install Mongo DB from here
  3. Install Mongo DB tools from here

Database Setup

  1. Create a file named database.json
  2. Add this data into database.json
{
  "_id": { "$oid": "642d286eb09a9ad84315fdf4" },
  "username": "admin",
  "password": "$2a$14$vOFw5FYpRLxu0y28foh1Mu9QNW7LObdMrI9qTtlsyuHxrmdcVIRae"
}
  1. Import data into database
mongoimport -d "school-erp" -c "admin" --type "json" --file "database.json"

Create index for students

  1. Open mongosh to execute commands.
  2. Run these commands in mongosh one by one.
use school-erp
db.students.createIndex({"name":"text","admissionNo":1,"applicationNo":1})

Server Setup

  1. Clone this repository and change directory

    git clone https://github.com/FulgurCode/school-erp-api
    cd school-erp-api
  2. Create .env file

    touch .env
  3. Store thease values in .env

    • PORT Port that server listen for requests

    • SECRET_KEY Secret key for cookie

    • MONGODB_URI Uri of mongodb database

    Example

    PORT=9000
    SECRET_KEY=secret_key
    MONGODB_URI=mongodb://localhost:27017
  4. Install go dependencies

    go mod tidy

Running the server

You can run the server by creating executable file and running or without it. For both following actions should be done in the project folder.

Using executable

go build .

This will create executable file for your Operating System. Now run the executable file for starting the server

You may have to give executable permission to the file

Without executable

go run .

Now the server is running in terminal.

Clone this wiki locally