Giter Site home page Giter Site logo

stacha-dev / tardis Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 809 KB

PHP based backend for web applications.

Home Page: https://stacha-dev.github.io/tardis/

License: MIT License

PHP 99.67% Shell 0.33%
api-rest php doctrine-orm phpstan phpunit composer orm

tardis's Introduction

API Service Stacha.dev

Instalation

  1. Clone repository: git clone https://github.com/Stacha-dev/tardis.git && cd tardis
  2. Run install script ./bin/install.sh <db_user> <db_password> <db_name>
  3. Generate password for root user composer app:password <password>

Development

  1. Update git pull develop to get recent commits
  2. Install composer dependencies composer install
  3. Load DB schema composer migrations:migrate and generate proxies composer orm:proxies
  4. Create new branch by git checkout -b <branch-name> follow this convention:
    • Feature feat/<feature-name>
    • Bugfix fix/<bugfix-name>
    • Chore chore/<chore-name>
  5. Commit changes to the remote branch
  6. In case of feature add PHP Unit test suite
  7. Create pull request into develop branch follow this convention
    • <type>(Scope): Description example: feat(User): Added user model

API

Endpoints: POSTMAN

Usefull Commands

App

composer app:password <password>    // Generates password

ORM

composer orm:create                 // Creates DB schema
composer orm:update                 // Updates DB schema
compsoer orm:drop                   // Drops DB schema

Migrations

composer migrations:diff            // Generates differences in DB schema
composer migrations:status          // Show migration status
composer migrations:migrate         // Migrate to latest migration
composert migrations:migrate:prev   // Migrate to previous migration

PHPStan

composer phpstan                    // Runs static analysis

Coding Standards

composer cs                         // Checks coding standarts
composer cs:fix                     // Fixes coding standarts

PHP Unit

composer test                       // Runs all unit tests
compsoer test:coverage              // Generates test coverage

tardis's People

Contributors

pchalupa avatar oliverstasa avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

tardis's Issues

Implement gallery tag

I would like to add tag to gallery. Tags should be simple strings like: carousel, press, ....

Hash passwords in DB

Description

In this time, passwords are stored in DB without hashing. Which is hudge security issue. We need to save passwords as hashes. To do that, I suggest to has password in user model src/Model/Entity/User.php method setPassword. This method is called when new user is creating. Then there is login method in src/Controller/User.php where you need to compare hashes. I don't know much about hashing algorithms, so use whatever you want.
I think about sending passwords as hashes from client, but we are using https only, sou I think this is not necessary.

Login method

Username from request body
$username = $body->getBodyData('username') ?? $username;
Pass from request body
$password = $body->getBodyData('password') ?? $password;
Query with find one by username and password, now the password should be hashed
$user = $this->entityManager->getRepository('App\Model\Entity\User')->findOneBy(array("username" => $username, "password" => $password));

Investigate and implement realtime capability

Describe your feature request

It would be nice to subscribe server side events on client side. This could be used for realtime experince in client app. Technology used for this, can be websockets od server siede events (sse), in coop with doctrine events.

Register routes refactoring

Refactor register route. Remove regex string and search for improvements.
Current state:

$router->register(RouteFactory::fromConstants(1, "GET", "@^(?<version>[0-9])/gallery$@", "getAll"))
->register(RouteFactory::fromConstants(1, "GET", "@^(?<version>[0-9]+)/gallery/(?<id>[0-9]+)$@", "getOneById", array("id")))
->register(RouteFactory::fromConstants(1, "GET", "@^(?<version>[0-9]+)/gallery/(?<alias>[a-z1-9-]+)$@", "getOneByAlias", array("alias")))
->register(RouteFactory::fromConstants(1, "GET", "@^(?<version>[0-9]+)/gallery/find/(?<key>[a-z1-9-]+)/(?<value>[a-z1-9-]+)$@", "find", array("key", "value")))
->register(RouteFactory::fromConstants(1, "POST", "@^(?<version>[0-9]+)/gallery$@", "create", array(), true))
->register(RouteFactory::fromConstants(1, "PUT", "@^(?<version>[0-9]+)/gallery/(?<id>[0-9]+)$@", "edit", array("id"), true))
->register(RouteFactory::fromConstants(1, "DELETE", "@^(?<version>[0-9]+)/gallery/(?<id>[0-9]+)$@", "delete", array("id"), true));

Implement gallery tag

I would like to add tag to gallery. Tags should be simple strings like: carousel, press, ....

Add possiblity to send e-mail

Expected Behavior

It is possible to send e-mail to one recipient without attachment. Sender will be provided by configuration.

Implement DB migrations

Describe your feature request
We should be able to generate db migrations to get compatybily between multiple versions of this project.

Describe the solution you'd like
We should implement Doctrine Migrations.

Update Postman endpoints

Description of the bug

Postman endpoints are obsolete, also there is some routes missing and naming is not clear.

Expected behavior

Up-to-date API endpoints.

Opravit problém s CORS při PUT a DELETE requestu.

Souvisí s předvojovým requestem OPTIONS, který nemá route a končí na 400.
Ideálně vytvořit třídu pro odesílání zpráv např Response::message("foo", 200), a přidat globální routu pro OPTIONS reqeusty.

Extend standard Exception class by response code.

Description

Generated exceptions are catche by src/Controller/App.php line 16. There I would like to get HTTP response code from exception object. It should be named like getHttpStatusCode without parametter. Response code should be provided in constructor, or by setter. Code should be in src/Lib/Exception/Exception.php and namespace App\Exception. Also create unit tests! Check your code by PHPStan and CS.

Links

List

  • Extended class

  • Pass PHPStan and CS

  • Cover code by unit test and it should pass

Custom page

There should be one universal option for creating custom text pages. As I imagine it, it should contain:

  • title (varchar => json)
  • content (text => json)
  • visibility (bool)
    This can be used various ways, when needed: special covid notices, post about relocation, etc. There should be also option to [add to menu] and link the page with a coresponding menu option.

Implement contact entity

Describe the solution you'd like
I would like to be able to create contact (person) with personal information. Also be able to edit and delete.

Add simple response method to view

Describe your feature request

After some actions where We don't need to response with data, there could be handy method witch basically render only some sort of standardized format like {"status": "ok"} or something like that. Sou the general workflow should looks like that:

action
$this->view->responseOk();
return

Method name is not definitely given, it can be differ. There could be another method with same purpose with inverse meaning.

Add menu entity

Expected Behavior

User should create own menu.

Actual Behavior

There is no menu entity.

Add posting time control

Any text content user posts should have time control - from when it starts to be public.

Example:
Create news and state it starts to be public immediately or in an hour or tomorrow etc.

Implement gallery tag

I would like to add tag to gallery. Tags should be simple strings like: carousel, press, ....

Add root user

  • Install DB fixtures
  • Add root user with random pass
  • Secure create user endpoint

File upload and storage

Let's make simple api end points to upload, list, delete files. Focus on images aditionaly on pdfs.

  • Upload

  • Delete

  • Helper class

  • Unit tests

Add utit test to mail lib

Describe your feature request

Mail library should have own unit tests. You can avoid send method. Add test to Assert\Text too.

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.