Giter VIP home page Giter VIP logo

api's Introduction

Dansdata API

Open API for retrieving information about social dances in Sweden.

Getting Started

The project makes use of VSCode's devcontainer feature to create a basic, common development environment. The following instructions assume you are using this environment. If you do not want to use a devcontainer, necessary steps to configure your local environment can be deduced from files in the .devcontainer directory.

To initialize/update your development database to match your current state:

$ npm run dev:db:push

To run the API locally

$ npm run dev

To create a new database migration:

$ npm run dev:db:migrate -- dev -- --name my_migration_name

To use prisma studio

$ npm run dev:db:studio

Environment Variables

This project uses environment variables for database connections and more.

Certain variables, such as cloudflare credentials, need to be configured manually for some features to work.

Please see src/env/index.ts for more details.

Testing

Unit tests can be run using

$ npm run test:unit

Integration tests can be run using

$ npm run test:integration

To run all tests, simply use

$ npm run test:all

The group a test is in is determined by an initial documentation comment, e.g.:

/**
 * @group unit
 */

See also jest-runner-groups.

Resetting the development database

Ususally npm run dev:db:push should be enough to apply your prisma changes to the database. However, sometimes it is necessary to perform a deeper clean.

To do this, connect to the database (the devcontainer comes with the SQLTools extension preconfigured for such a connection - use the database icon in the left bar of vscode) and run

DROP SCHEMA auth CASCADE;
DROP SCHEMA events CASCADE;
DROP SCHEMA portal CASCADE;
DROP SCHEMA profiles CASCADE;
DROP SCHEMA public CASCADE;
DROP SCHEMA storage CASCADE;
DROP SCHEMA logs CASCADE;

Then use npm run dev:db:push to re-initialize your development database.

Contributing

Dansdata is a project by dancers, for dancers. Contributions are welcome!

Please see CONTRIBUTING.md for guidelines.

About Dansdata.se

Dansdata (lit. "dance data") is an open API for information relating to social dancing in Sweden.

Felix Zedén Yverås is the project's current maintainer.

License

MIT

api's People

Contributors

felixzy avatar

Watchers

 avatar

api's Issues

Automatically remove dangling images from database

Background

Images uploaded to the API are stored using Cloudflare images. We also store a light reference in our own database. This reference is created when the client requests to upload a new image.

Problem

Our local image reference may become stale:

  • If an image upload is initiated but not completed
  • If all references to an image are removed but not the image itself

Suggested Solution

We should have a nightly script/function/job that verifies the integrity of our local image reference against Cloudflare. It is probably a bad idea to check every single image each night so we should try to do something smart, e.g. keep a list of recently created image references and modified image relations, check a subset of the images each time, etc.

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.