github.com/alextanhongpin/crystal-lucky
master / published Jul 21, 2021 / repository
Crystal Lucky Framework
crystal_lucky
This is a project written using Lucky. Enjoy!
Setting up the project
- Install required dependencies
- Update database settings in
config/database.cr - Run
script/setup - Run
lucky devto start the app
Learning Lucky
Lucky uses the Crystal programming language. You can learn about Lucky from the Lucky Guides.
Installation
- Installation of Crystal is done using asdf version manager. At the time this is written, Lucky framework only supports Crystal v0.36.1, not v1.0.x.
- Overmind is used as the process manager.
API
$ curl -X POST -H 'content-type: application/json' -d '{"user":{"email": "john.doe@mail.com", "password": "123456", "password_confirmation":"123456"}}' http://127.0.0.1:5000/api/sign_ups
{"token":<generated_token>}%
# Visit
http://127.0.0.1:5000/api/me?auth_token=<generated_token>
Creating a new model
$ lucky gen.model Post
$ lucky db.migrate
API
$ curl -X POST -H 'content-type: application/json' -d '{"post":{"body": "hello world"}}' http://127.0.0.1:5000/api/posts
{"id":"7cb6e887-cce5-4584-a7e0-fbbecaaf312e","body":"hello world"}%
# Visit
http://127.0.0.1:5000/api/posts
API
- Api
- ApiAction
Include modules and add methods that are for all API requests
- AppDatabase
- AppServer
- BaseEmail
Learn about sending emails https://luckyframework.org/guides/emails/sending-emails-with-carbon
- BaseModel
- BaseSerializer
- ErrorSerializer
This is the default error serializer generated by Lucky.
- Errors
- Home
- Merchant
- MerchantQuery
- MerchantSerializer
- PasswordValidations
- Post
- PostQuery
- PostSerializer
- RequestPasswordReset
- ResetPassword
- SaveMerchant
- SavePost
- SignInUser
- SignUpUser
- User
- UserFromEmail
- UserQuery
- UserSerializer
- UserToken
Generates and decodes JSON Web Tokens for Authenticating users.