Giter Site home page Giter Site logo

mycookbook / api Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 2.18 MB

cookbook api - this is the core application that powers all the services used to make cookbooksHQ function.

PHP 86.36% Hack 9.66% Procfile 0.01% Dockerfile 0.25% JavaScript 0.01% SCSS 0.01% Blade 3.16% Makefile 0.55%
nigerian africa cookbookshq cookbook canada global canadian laravel

api's Introduction

Prerequisites

open ~/.bashrc OR
open ~/.zshrc

# add this line
alias composer='/usr/local/bin/composer'

# remember to source the file.
e.g
source ~/.bashrc OR
source ~/.zshrc
  • Ensure php is correctly installed on your machine. You can use brew, follow the instructions to update your httpd.conf file and restart apache.
  • install the docker desktop app suitable for your hardware https://www.docker.com/products/docker-desktop/

Installation

Use the make command to setup the project like so:

make install

This command spins up the containers, install project dependencies, creates a barebone .env file which you can update as needed, sets the app key etc For a full glossary of all the make commands, look in the Makefile in the project root.

Now you can access the app via:

http://localhost:8080/api/v1/ping

To run a command directly in the "app" container, you could use docker-compose exec app [command], for example

docker-compose exec app php artisan env
# which prints the application environment

Contributing

  1. Always rebase your branch against the base branch git rebase -i --autosquash origin/staging
  2. Strictly adhere to branch naming rules e.g feature/descriptive-branch-name, bugfix/descriptive-branch-name etc (hotfix, chore)

Testing in dev

  • Follow this guide to learn how to setup phpunit in phpstorm.
  • You can also use any of the following make cmds to run tests
make test
make test_unit
make test_api

Help

To see a list of all the make commands, type make in the project root. It will dispplay the full list of available commands you can use.

Examples:

Alt text

Setup PHPStorm + + Docker + Xdebug + postman

  • Open settings by pressing (cmd + ,) button
  • Under PHP, add a new CLI interpreter

add-new-cli-interpreter1.png

  • Select From Docker, Vagrant ... option

  • Select Docker Compose, set the configuration file to ./docker-compose.yml and the service select app add-new-cli-interpreter2.png

  • Now your PHP interpreter settings hosuld look like this xdebug-php.png

  • Next, you want to set up the test framework, click the plus sign and select PHPUnit by remote interpreter test-framework1.png

  • Select the interpreter you just created from the dropdown list test-framework2.png

  • Now you can start debugging, set a break point in any controller class and run the test associated with it in debug mode

Listening for requests from postman

  • First step is to set up a server server.png
  • On postman add this parameter. When postman detects this in a request, it creates a cookie with the value of XDEBUG_SESSION_START. This has an expiry time of 30 minutes so you dont have to include it in your requests all the time.
XDEBUG_SESSION_START=PHPSTORM
  • Finally, tell postman to listen for PHP Debug Connections php-debug-connections.png

  • Set a break point in the code called by the endpoint you are consuming on postman, hit send to start debugging

api's People

Contributors

dependabot[bot] avatar fokosun avatar johnkingzy avatar laravel-shift avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

api's Issues

search query syntax

The search query syntax is broken for most of it

  • find and fix the broken ones
  • fix regular search

As an authenticated user, I want to be able to save my new recipe as a draft

Dev Notes

  • does not require a new endpoint to create a recipe

  • requires creating a new migration

  • update the create recipe code to save the recipe as a draft if draft is set to true in the request

  • When a recipe is not in draft, it's considered a final state and transition back to drafts in not allowed.

  • the newly created table should contain only the recipe id [id, recipe_id], the recipe should still be stored in the recipes table

  • add a new attribute to the recipe model [is_draft]

  • add a new attribute to the user model [drafts] this should be a collection of all the user recipes that are drafts i.e each item in the collection must be a serialized copy of the recipe instance

#206

TikTok videos

Create an endpoint that will return a list of tiktok videos of an authenticated user

Dev notes

SPIKE: As an authenticated user, I want to be able to see items on my for you page

Dev Notes

  • requires a scheduled job that will run daily (twice a day or more)

  • the job will write for you page data to pub/sub topics

  • For users having user preferences, the data written to pub/sub will be driven by their configured preferences

  • The cronjob will alongside also publish generic data to pub/sub topics, this will determine what users without user preferences see on their fir you page

  • Need to figure out the most cost effective approach to use, between google pub/sub or plain simple pusher

  • Figure out how to setup supervisor on heroku to keep the schedular running

Tiktok social auth with socialite

Problem
When some users try to login with tiktok, their user info is not returned. It only works for admin at the moment..

Describe alternatives you've considered
Swap current implementation to use Socialte to help fix the problem.

As a user, I want to be able to register/signin with basic auth

Dev Notes

  • does not require a new endpoint to register
  • does not require a new endpoint to signin
  • register endpoint must now require username (username must be unique)
  • ensure unique constraint is applied to the username i.e name_slug field in the users table
  • another endpoint to verify uniqueness of username is required
POST /api/v1/auth/register

request {
    body: {
        name: required
        email: required|email|unique
        password: required
        username: required|unique
    }
}
POST /api/v1/auth/signin

request {
    body: {
        email: required|exists
        password: required
    }
}
GET /api/v1/username-available?q={username}

response {
    code: 200 OK
    body: true
}

response {
    code: 400
    body: false
}

Fix broken CI

CI is complete broken
Unable to run tests locally inside docker

refactor codebase

  • use a common request class to validate requests
  • have transformer classes to transform responses
  • many more ...

As a user, I want to be able to configure my preferences

Dev Notes

  • requires a new api endpoint
  • requires creating a new migration
POST /api/v1/users/{user_id}/preferences

header {
    Authorization: Bearer {token}
}

User preferences can be stored as a json representation in the user_preferences table.

The following preferences can be set:

- default cookbook id
- default image picker
- topics
- store fronts (urls)

Note

  • add user preferences as an attribute to the user model
  • add coverage for this change in the tests

enable logging

either

  • logdna
  • or some other logging and monitoring service

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.