This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POSTGRES_DB=postgres | |
POSTGRES_USER=postgres | |
POSTGRES_PASSWORD=p@ssw0rd | |
POSTGRES_HOST=localhost | |
POSTGRES_PORT=5432 | |
JWT_SECRET=very secret | |
JWT_ACCESS_EXP=1800 | |
JWT_REFRESH_EXP=864000 | |
JWT_ALGORITHM=HS256 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum | |
from marshmallow import fields | |
class EnumField(fields.Str): | |
enum: Enum = None | |
default_error_messages = { | |
'invalid_string': 'Not a valid string.', | |
'invalid_enum': 'Not a valid value, has to be one of ({values}).', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getTextColorBasedOnBg } from './utils' | |
getTextColorBasedOnBg('#00334d'); // -> 'white' | |
getTextColorBasedOnBg('#fdaaaf'); // -> 'black' | |
getTextColorBasedOnBg('#fdffaf'); // -> 'black' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aiohttp import web | |
from app.middlewares import jwt_middleware_with_cors | |
app = web.Application( | |
middlewares=[ | |
jwt_middleware_with_cors( | |
secret_or_pub_key='very secret', | |
algorithms=['HS256'], | |
request_property='user', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
export class SomeApi { | |
async getAll(): Promise<any[]> { | |
const { data } = await axios.get('/items'); // `fetch` could be used here | |
return data; | |
} | |
async update(id: number, itemData: any) { | |
const { data } = await axios.put(`/items/${id}`, itemData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import enum | |
from uuid import uuid4 | |
import sqlalchemy as sa | |
from sqlalchemy.dialects.postgresql import UUID | |
user_draw_source_relationship = sa.Table( | |
'users_draw_sources', meta, | |
sa.Column('user_id', UUID(as_uuid=True), sa.ForeignKey('users.id'), primary_key=True), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSerializer(serializers.ModelSerializer): | |
clients = serializers.ListField(source='client_names') # Model's property to retrieve `clients` names | |
sales = serializers.IntegerField(source='get_sales_overall_amount') # Model's method | |
address = serializers.CharField(source='address.street') | |
manager_name = serializers.CharField(source='manager.full_name') | |
@staticmethod | |
def setup_eager_loading(queryset): | |
""" Perform necessary eager loading of data. """ |