Giter Site home page Giter Site logo

bunbackend's Introduction

Welcome To BunBackend

This is the backend for the the challenge. Check out the front-end Here.

Terminal

To install dependencies:

bun install

To run app, (http://localhost:5500):

bun run dev

To migrate database (if you decide to delete "sqlite.db"):

bun run ./src/database/migrate.ts 

Routes

Currently Implemented Routes Include:

Requests-Releated:

Route Parameter Body Functionality
/uploadData JSON: request[] inserts data into DB. returns time taken.
/getAllRequests returns all requests in DB.
/getRequest/:Requestid RequestID returns request with specified RequestID.
/getAllAccounts returns all accountRequests in DB.
/getAccount/:Requestid RequestID returns accountRequest with specified RequestID.
/getAllActivityRequests returns all activityRequests in DB.
/getActivityRequest/:Requestid RequestID returns activityRequest with specified RequestID.

Permissions-Releated:

Route Parameter Body Functionality
/getAccountPermissions/:accountID AccountID returns specified account permissions as string[].
/addPermission/:name Name inserts permission with specified name.
/getAllPermissions returns all permissions in DB.

Activities-Releated:

Route Parameter Body Functionality
/getCompanyActivities/:id ActivityRequestID returns specified company activities as string[].
/addActivity/:name Name inserts activity with specified name.
/getAllActivities returns all activities in DB.

Validation

There are many rules to inserting data into the database, some include:

  1. Request ID already exists in database.
  2. Request Type not in range [1-5].
  3. Request Status not in range [1-3].
  4. Row data does not match any request type data structure.
  5. Adding Account with permission not in database (have to add it first).
  6. Adding CompanyActivity with activity not in database (have to add it first).
  7. Adding Permission using a name that already exists (Permission names are unique).
  8. Adding Activity using a name that already exists (Activity names are unique).

Violating any of the rules will result in omitting the row trying to insert. and no response will be provided to the front-end, the code will continue to add the following rows as long as they match the rules.

SQLite Schema

SchemaLight

Packages, Libraries and frameworks

  • BunJS: JavaScript Runtime, faster than NodeJS.
  • ElysiaJS: BunJS web framework for API routes and routing.
  • Sqlite and Drizzle ORM: Sqlite Database with Drizzle Object–relational mapping built to work best with TypeScript types support for maximum type safety.

bunbackend's People

Contributors

adam-442 avatar

Watchers

 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.