GithubHelp home page GithubHelp logo

poc-charactersapi-prisma's Introduction

poc-characterapi-prisma

This is a simple proof of concept API written in TypeScript & Prisma for managing characters.

Endpoints

  • PUT /generate: Creates or updates a character
  • GET /worlds/:id?: Retrieves a specific world by its id or all worlds if id is not specified
  • GET /guilds/:id?: Retrieves a specific guild by its id or all guilds if id is not specified
  • GET /characters/:id?: Retrieves a specific character by its id or all characters if id is not specified
  • DELETE /character/:id: Deletes a specific character by its id
  • DELETE /guild/:id: Deletes a specific guild by its id

Installation

Clone the repository: git clone https://github.com/yuridesideri/poc-characterapi-ts.git

Install dependencies: npm install

Run Postgres

You must have node v16.19.0 (not higher nor lower) installed - prisma currently works best with this version

Run nvm use to automatically switch node to the correct version

Rename .env.example to .env

Insert into .env your database string ex: postgres://user:password@host:5432/database_name and your port ex: 4000

Run npm run prisma:init to initialize the tables and seed the database, press y when prompted.

Start the server: npm run dev

Usage

The API can be accessed at http://localhost:4000. (Default)

In the Route: PUT /generate - Creates/Updated (base in name) a new character and/or guild, it needs those fields:

{
  "guild": { //optional
    "id": 4, //optional
    "name": "test guild 3.0", //unique
    "description": "just a normal guild dsafds.0", //unique
    "membersId":[10, 9, 5]
  },
  "character": { //optional
      	"id": 1, //optional
	"name": "Grofdsafgu", //unique
	"race": "Tridafdsactyls",
	"description": "Lorem Ipsum", //unique 
	"age": 900,
	"height": 42,
	"u_obj": "jeafdadi_suite",
	"sex": "male", //male|female|other
	"world_born_id": 1,
	"guild_id": 4 //optional
  }
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

poc-charactersapi-prisma's People

Contributors

yuridesideri 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.