A project to learn Node.js, Express.js and Typescript
It provides a crud OpenAPI json web service with a few endpoints for building Magic the Gathering decks.
Endpoints are documented in the openapi.yml file in the root of the project.
You can import the yaml into the Swagger editor to visualise the api.
- Visit https://editor-next.swagger.io/
- File > Import URL
- Enter
https://raw.githubusercontent.com/davidyell/Learning-Express-MTG-Api/main/openapi-dist.yaml
For first time install, after the dependancies, you'll need to populate the database with some data.
- Install the dependancies with
yarn install
- Copy the
.env.example
file to.env
and update your database path - Create the database and schema
yarn prisma db push
- Insert the card data
sqlite3 -init ./infrastructure/sql/import-all.txt ./infrastructure/database.sqlite
then.quit
(takes about 2 mins) - Seed some players and decks
yarn prisma db seed
- Run the dev server
yarn run dev
- Visit http://localhost:3001/api/decks or send a request from Postman to see some MtG decks
Two test suites exist, a unit and integration suite. These can be run with yarn run test:unit
and yarn run test:integration
, or run everything with yarn run test
An integration testing database must be created for the integration tests to run, which can be setup with ./infrastructure/setup-test-db.sh
, you'll need to quit from sqlite3
after the import with .quit
🎓 Learn to play Magic the Gathering! https://magic.wizards.com/en/intro
🙅 Not officially affiliated or endorsed by Wizards of the Coast or Magic the Gathering
🙇♂️ Thanks to MTGJSON for their free data https://mtgjson.com/downloads/all-files/
👍 Node.js
🌍 Express
🎓 I bought an excellent Typescript course on Udemy. Understanding TypeScript - 2022 Edition
📺 They also have a great YouTube channel Academind
MTG Deck Building API Copyright (C) 2022 David Yell [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.