Git Product home page Git Product logo

aasf-website-backend's Introduction

AASF-Website-Backend

NOTE: THIS REPOSITORY IS OPEN ONLY TO THE STUDENTS OF IIITM GWALIOR, INDIA.

Newly built backend for AASF Website(revamped) and Mobile App.

Core Functions

  • Admin-Only Functions:

    • Manage events.
    • Add points for contest winners and goodie questions.
    • Get QR Code to mark attendance for a particular event.
    • Send report emails.
    • Add and edit user details.
    • Send Push Notifications.
  • Events:

    • Fetch events.
    • Mark attendance for an event.
  • Users:

    • Login.
    • Fetch his/her details.
    • Fetch Leaderboard.
    • Change password and profile picture.

Get Started

Get started developing...

  • You will need a .env file in the root folder for the system to run successfully. An example for the .env file has been written in .env.example. Modify the environment variables as you need and required before starting. Set NODE_ENV to development while running it in development mode.
  • You will also need a firebase.json file at the root level. You can download your own from the firebase console. You can find instructions on how to get this file in the first couple of paragraphs of this article.
  • To get an Azure Connection String, signup on Azure(preferably using your University email ID to avail student benefits), create a new Storage Account, go to Access Keys within your storage account, click on Show Access Keys and copy the first Connection String and paste it in the .env file.
  • User has to be an admin for performing any admin-only functions. Admins can only be created directly from the database and not via any API.
  • To make yourself an admin, add a user document in the users' collection in the database named AASF-DEV(We use MongoDB for our database, so you can either use Mongo Shell or MongoDB Compass if you're running an instance locally, or use the MongoDB Atlas interface if you wish to use the cloud).
  • Once you have created an admin user, start the server by following the below commands.
  • Before starting the database, please create the following index using mongo shell db.otp.createIndex( {"createdAt": 1 } , {expireAfterSeconds: 3600} );
# install deps
npm install

# run in development mode
npm run dev
  • Once the server is up and running, you can open it in localhost:3000 to view the documentation. The first route in the documentation is the login route. Login using the id and password that you just set(roll parameter is the primary key you set in the database document). You must receive a token if everything goes well.
  • Create a folder named users under the public folder.
  • For uploading new users, you will have to use Postman since uploading a CSV file is not yet supported in Swagger UI. The route for uploading new users is /admin/users/upload. Make you sure pass the JWT token in the Authorization header as bearer {token}. Upload a Sample CSV to add new users to the database. The file has to be uploaded in the form-data body with the field name as users.
  • You can add sample events in the similar manner. Refer to routes.js files in the server folder for the main routes and routes.js files in sub-folders to find sub-routes. Sample CSV for events. Modify the dates of the events as needed.
  • Once there are admin(s), users and events in the database, you're all set to roll. Go through the code and try to understand the code flow. On a high level, the flow goes like:-
    • An API is hit from the client-side.
    • The main route is matched with a route in the routes.js folder in the server folder.
    • A router is selected based on the route given, and the request is passed on to a controller.
    • The controller receives the request and delegates the operations to be performed to services.
    • The services perform the operations and return to the controller, which then sends the response to the client.
    • Overall, the control sequence is client request -> server/routes.js -> server/api/controllers/{some controller}/router.js -> server/api/controllers/{some controller}/controller.js -> server/api/services/{some service} -> server/api/controllers/{some controller}/controller.js -> client response.
  • In case you have any doubts, feel free to post it on the AASF Developers' Circle Facebook Group or send an email to [email protected] with the subject [AASF-WEBSITE-BACKEND] Query.

Install Dependencies

Install all package dependencies (one time operation)

npm install

Run It

Run in development mode:

Runs the application is development mode. Should not be used in production

npm run dev

Run in production mode:

Compiles the application and starts it in production production mode.

npm run compile
npm start

Test It

Run the Mocha unit tests

npm test

Try It

Debug It

Debug the server:

npm run dev:debug

Debug Tests

npm run test:debug

Lint It

View prettier linter output

npm run lint

Fix all prettier linter errors

npm run lint

Contributors


aasf-website-backend's People

Contributors

debadityapal avatar gunashekar02 avatar hs2361 avatar kailash360 avatar kshitij-404 avatar kunaljain0212 avatar manishdangi98 avatar manishprivet avatar shikhar15606 avatar sohan2410 avatar tend2infinity avatar xdragon2002 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.