Coder Social home page Coder Social logo

gorecipes's Introduction

gorecipes

๐Ÿฅš Recipe Manager written in go (port of https://github.com/kylemarsh/recipelister)

Development

To run local dev server manually using an in-memory sqlite database:

go build
./gorecipes --config mem.config --debug --bootstrap

To build for deployment:

make dist

This builds the binary and a config file and places them in the ./dist subdirectory. make clean removes that subdirectory. If you want to also bootstrap a sqlite database to persist, make sqlite will do that and place the database file in ./dist as well.

Configuration

gorecipes uses the following configuration values, which can be specified in gorecipes.config or another config file specified with the --config flag. There is also a --force flag to force bootstrapping a database that is already populated. Be careful not to use this on a DB you care about!

  • Debug: enable debugging output, API commands, etc. Default false
  • DbDialect: database type to use (sqlite3 and mysql, for example)
  • DbDSN: data source name for the db (filename or :memory: or sqlite; "user:password@host/db" for mysql...)
  • JwtSecret: secret used to generate Json Web Tokens

Make accepts the following environment variables, which align with their counterparts above.

  • DEBUG
  • DB_DIALECT
  • DB_DSN
  • JWT_SECRET
  • CONFIG

API

Example requests made with curl against development server (localhost:8080)

Unauthenticated Requests

  • List all recipes: curl http://localhost:8080/recipes/
  • List all labels: curl http://localhost:8080/labels/
  • Login: curl -F"username=foo" -F"password=bar" http://localhost:8080/login/

Authenticated Requests

  • Get full recipe (single recipe): curl -H "x-access-token: $TOKEN" http://localhost:8080/priv/recipe/$RECIPE_ID
  • Delete recipe: curl -X DELETE -H "x-access-token: $TOKEN" http://localhost:8080/priv/recipe/$RECIPE_ID
  • Get full recipe (all recipes): curl -H "x-access-token: $TOKEN" http://localhost:8080/priv/recipes/

Debugging Requests

  • Get a signed JWT: curl http://localhost:8080/debug/getToken/
  • Check JWT validity: curl -H "x-access-token: $TOKEN" http://localhost:8080/debug/checkToken/
  • Get the bcrypt hash of a plaintext password: curl -F"password=bar" http://localhost:8080/debug/hashPassword/

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.