| @ -0,0 +1,9 @@ | |||||
| root = true | |||||
| [*.cr] | |||||
| charset = utf-8 | |||||
| end_of_line = lf | |||||
| insert_final_newline = true | |||||
| indent_style = space | |||||
| indent_size = 2 | |||||
| trim_trailing_whitespace = true | |||||
| @ -0,0 +1,5 @@ | |||||
| /docs/ | |||||
| /lib/ | |||||
| /bin/ | |||||
| /.shards/ | |||||
| *.dwarf | |||||
| @ -0,0 +1 @@ | |||||
| language: crystal | |||||
| @ -0,0 +1,10 @@ | |||||
| FROM alpine:latest | |||||
| RUN apk add --no-cache crystal shards openssl openssl-dev musl-dev libc6-compat | |||||
| COPY . /opt/app/ | |||||
| RUN cd /opt/app && \ | |||||
| shards | |||||
| RUN cd /opt/app/ && crystal build src/sales_backend.cr | |||||
| CMD /opt/app/sales_backend | |||||
| @ -0,0 +1,21 @@ | |||||
| The MIT License (MIT) | |||||
| Copyright (c) 2018 Ludovic 'Archivist' Lagouardette | |||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| of this software and associated documentation files (the "Software"), to deal | |||||
| in the Software without restriction, including without limitation the rights | |||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||||
| copies of the Software, and to permit persons to whom the Software is | |||||
| furnished to do so, subject to the following conditions: | |||||
| The above copyright notice and this permission notice shall be included in | |||||
| all copies or substantial portions of the Software. | |||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||||
| THE SOFTWARE. | |||||
| @ -0,0 +1,27 @@ | |||||
| # sales_backend | |||||
| TODO: Write a description here | |||||
| ## Installation | |||||
| TODO: Write installation instructions here | |||||
| ## Usage | |||||
| TODO: Write usage instructions here | |||||
| ## Development | |||||
| TODO: Write development instructions here | |||||
| ## Contributing | |||||
| 1. Fork it (<https://github.com/your-github-user/sales_backend/fork>) | |||||
| 2. Create your feature branch (`git checkout -b my-new-feature`) | |||||
| 3. Commit your changes (`git commit -am 'Add some feature'`) | |||||
| 4. Push to the branch (`git push origin my-new-feature`) | |||||
| 5. Create a new Pull Request | |||||
| ## Contributors | |||||
| - [your-github-user](https://github.com/your-github-user) Ludovic 'Archivist' Lagouardette - creator, maintainer | |||||
| @ -0,0 +1,14 @@ | |||||
| version: 1.0 | |||||
| shards: | |||||
| kemal: | |||||
| github: kemalcr/kemal | |||||
| version: 0.23.0 | |||||
| kilt: | |||||
| github: jeromegn/kilt | |||||
| version: 0.4.0 | |||||
| radix: | |||||
| github: luislavena/radix | |||||
| version: 0.3.8 | |||||
| @ -0,0 +1,17 @@ | |||||
| name: sales_backend | |||||
| version: 0.1.0 | |||||
| authors: | |||||
| - Ludovic 'Archivist' Lagouardette <lagouardette.ludovic@gmail.com> | |||||
| targets: | |||||
| sales_backend: | |||||
| main: src/sales_backend.cr | |||||
| crystal: 0.25.0 | |||||
| dependencies: | |||||
| kemal: | |||||
| github: kemalcr/kemal | |||||
| license: MIT | |||||
| @ -0,0 +1,9 @@ | |||||
| require "./spec_helper" | |||||
| describe SalesBackend do | |||||
| # TODO: Write tests | |||||
| it "works" do | |||||
| false.should eq(true) | |||||
| end | |||||
| end | |||||
| @ -0,0 +1,2 @@ | |||||
| require "spec" | |||||
| require "../src/sales_backend" | |||||
| @ -0,0 +1,22 @@ | |||||
| require "json" | |||||
| enum Country | |||||
| FR, | |||||
| NL, | |||||
| DE, | |||||
| IT, | |||||
| EI, | |||||
| GB, | |||||
| end | |||||
| class Address | |||||
| JSON.mapping( | |||||
| name: String, | |||||
| address1: String, | |||||
| address2: {type: String, nilable: true}, | |||||
| postcode: String, | |||||
| city: String, | |||||
| country: Country, | |||||
| is_default: Bool | |||||
| ) | |||||
| end | |||||
| @ -0,0 +1,11 @@ | |||||
| require "json" | |||||
| require "./invoice_line" | |||||
| require "./address" | |||||
| class Invoice | |||||
| JSON.mapping( | |||||
| items: Array(InvoiceLine), | |||||
| invoicing_address: Address, | |||||
| delivery_address: Address | |||||
| ) | |||||
| end | |||||
| @ -0,0 +1,9 @@ | |||||
| require "json" | |||||
| require "./product" | |||||
| class InvoiceLine | |||||
| JSON.mapping( | |||||
| item: Product, | |||||
| quantity: Float64 | |||||
| ) | |||||
| end | |||||
| @ -0,0 +1,13 @@ | |||||
| require "json" | |||||
| class Product | |||||
| JSON.mapping( | |||||
| price: {type: Float64, nilable: true}, | |||||
| tax_rate: {type: Float64, nilable: true}, | |||||
| name: {type: String, nilable: true}, | |||||
| description: {type: String, nilable: true}, | |||||
| pic_url: {type: String, nilable: true}, | |||||
| id: Int64, | |||||
| ) | |||||
| end | |||||
| @ -0,0 +1,21 @@ | |||||
| require "json" | |||||
| require "uuid" | |||||
| require "uuid/json" | |||||
| require "crypto/bcrypt/password" | |||||
| require "./invoice" | |||||
| enum UserType | |||||
| Normal=0, | |||||
| Administrator=1, | |||||
| end | |||||
| class User | |||||
| JSON.mapping( | |||||
| addresses: {type: Array(Address), nilable: true}, | |||||
| invoices: {type: Array(Invoice), nilable: true}, | |||||
| tokens: {type: Array(UUID), nilable: true}, | |||||
| email: String, | |||||
| password_hash: {type: String, nilable: true}, | |||||
| type: {type: UserType, default: UserType::Normal}, | |||||
| ) | |||||
| end | |||||
| @ -0,0 +1,3 @@ | |||||
| module SalesBackend | |||||
| VERSION = "0.1.0" | |||||
| end | |||||