Parcourir la source

Initial commit

master
Archivist il y a 5 ans
révision
94e2321667
17 fichiers modifiés avec 254 ajouts et 0 suppressions
  1. +9
    -0
      .editorconfig
  2. +5
    -0
      .gitignore
  3. +1
    -0
      .travis.yml
  4. +10
    -0
      Dockerfile
  5. +21
    -0
      LICENSE
  6. +27
    -0
      README.md
  7. +14
    -0
      shard.lock
  8. +17
    -0
      shard.yml
  9. +9
    -0
      spec/sales_backend_spec.cr
  10. +2
    -0
      spec/spec_helper.cr
  11. +60
    -0
      src/sales_backend.cr
  12. +22
    -0
      src/sales_backend/address.cr
  13. +11
    -0
      src/sales_backend/invoice.cr
  14. +9
    -0
      src/sales_backend/invoice_line.cr
  15. +13
    -0
      src/sales_backend/product.cr
  16. +21
    -0
      src/sales_backend/user.cr
  17. +3
    -0
      src/sales_backend/version.cr

+ 9
- 0
.editorconfig Voir le fichier

@ -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

+ 5
- 0
.gitignore Voir le fichier

@ -0,0 +1,5 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf

+ 1
- 0
.travis.yml Voir le fichier

@ -0,0 +1 @@
language: crystal

+ 10
- 0
Dockerfile Voir le fichier

@ -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

+ 21
- 0
LICENSE Voir le fichier

@ -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.

+ 27
- 0
README.md Voir le fichier

@ -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

+ 14
- 0
shard.lock Voir le fichier

@ -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

+ 17
- 0
shard.yml Voir le fichier

@ -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

+ 9
- 0
spec/sales_backend_spec.cr Voir le fichier

@ -0,0 +1,9 @@
require "./spec_helper"
describe SalesBackend do
# TODO: Write tests
it "works" do
false.should eq(true)
end
end

+ 2
- 0
spec/spec_helper.cr Voir le fichier

@ -0,0 +1,2 @@
require "spec"
require "../src/sales_backend"

+ 60
- 0
src/sales_backend.cr
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 22
- 0
src/sales_backend/address.cr Voir le fichier

@ -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

+ 11
- 0
src/sales_backend/invoice.cr Voir le fichier

@ -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

+ 9
- 0
src/sales_backend/invoice_line.cr Voir le fichier

@ -0,0 +1,9 @@
require "json"
require "./product"
class InvoiceLine
JSON.mapping(
item: Product,
quantity: Float64
)
end

+ 13
- 0
src/sales_backend/product.cr Voir le fichier

@ -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

+ 21
- 0
src/sales_backend/user.cr Voir le fichier

@ -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

+ 3
- 0
src/sales_backend/version.cr Voir le fichier

@ -0,0 +1,3 @@
module SalesBackend
VERSION = "0.1.0"
end

Chargement…
Annuler
Enregistrer