Giter Site home page Giter Site logo

dungeon-crawler-be's Introduction

Summary

A RESTful API that is a part of the Untitled Dungeon Crawler project. This API has two endpoints which return either a single NPC(non-player character) or all the NPCs. The NPC model has full CRUD (Create, Read, Update, Delete) implemented.

link to the API production site: https://whispering-temple-46123.herokuapp.com/api/v1/npcs

link to the Front-end Repo: https://github.com/Maxwell-Baird/Dungeon-Crawler

Link to the game: http://untitled-dungeon-crawler.herokuapp.com/

Contributors

Maxwell Baird, Ruby Rinken, Justin Corbin, Trond Makonese, DeMarcus Kirby

Setup

To setup the project you will need to have python 3.8, get-pip, and postgresql installed. After installing those apps you will pull down this repo. Then you will need to create a database callled dungeoncrawler using the username postgres. You will then need to use the following commands:

$python3 -m venv env

$source env/bin/activate

$python get-pip.py

$pip install django

$pip install djangorestframework

$pip install django-cors-headers

$pip install psycopg2-binary

$python manage.py makemigration

$python manage.py migrate

$python manage.py loaddata fixtures/npc.json

To run the server use the following command:

$python manage.py runserver 8000

This will open the app at localhost:8000 where you can test the endpoints

Endpoints

GET /api/v1/npcs This endpoint will return all NPCs inside the database

POST /api/v1/npcs This endpoint allows the user to create a new NPC which will then be added to the database. The data will be sent through the body as a JSON object.

DELETE /api/v1/npcs This endpoint will remove all NPCs from the database.

GET /api/v1/npcs/{id} This endpoint will return a single NPC based off the id given in the header.

PUT /api/v1/npcs/{id} This endpoint will update a single NPC attributes. The data that will replace the attributes will be sent through the body as a JSON object. At the moment there is bug which requires the PUT to must have the dialogue and options also sent in order for the update to happen.

DELETE /api/v1/npcs/{id} This endpoint will delete a NPC based off the id that was sent through the header.

Commands

Reset database: $python manage.py dumpdata dungeon.npc

Seed database: $python manage.py loaddata fixtures/npc.json

Start server: $python manage.py runserver 8000

Run test: $python manage.py test

Create the DATABASE

$ psql -U postgresq

postgres=# CREATE DATABASE dungeoncrawler;

postgres=# \q

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.