Giter VIP home page Giter VIP logo

nim-basolato's Introduction

Basolato Framework


An asynchronous multiprocessing full-stack web framework for Nim, based on asynchttpserver.

⚠️ This project is under heavy development. It's not yet production-ready. ⚠️

The only supported OS are Alpine, Debian, and Ubuntu.

FROM ubuntu:22.04

# prevent timezone dialogue
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update --fix-missing && \
    apt upgrade -y
RUN apt install -y --fix-missing \
        gcc \
        g++ \
        xz-utils \
        ca-certificates \
        curl \
        git \
        sqlite3 \
        libpq-dev \
        libmariadb-dev \
        libsass-dev

ARG VERSION="2.0.0"
WORKDIR /root
RUN curl https://nim-lang.org/choosenim/init.sh -o init.sh
RUN sh init.sh -y
RUN rm -f init.sh
ENV PATH $PATH:/root/.nimble/bin
RUN choosenim ${VERSION}

ENV PATH $PATH:/root/.nimble/bin
WORKDIR /root/project
COPY ./basolato.nimble .
RUN nimble install -y -d
RUN git config --global --add safe.directory /root/project

Table of Contents

Introduction

Basolato extends asynchttpserver, an implements a high performance asynchronous HTTP server in Nim std library, while also adding features for full-stack development. It was also heavily inspired by other frameworks:

Language Framework
Ruby Rails
PHP Laravel
Python Masonite
Java/Scala Play
Go Revel

Set up your environment

In order to start using Basolato, you'll first need a working Nim installation. You can find installation instructions for Nim here. Once installed, make sure Nimble, Nim's package manager, is already in your PATH. If not, add .nimble/bin in your favorite shell.

export PATH=$PATH:~/.nimble/bin

Dependencies

The framework depends on several libraries (installed automatically by Nimble):

  • allographer, a library for building queries.
  • bcrypt, used for hashing passwords.
  • faker, for generating fake data.
  • sass, provides a Sass/SCSS to CSS compiler for Nim through bindings to libsass.

Installation

You can install Basolato easily using Nimble:

nimble install https://github.com/itsumura-h/nim-basolato

After installing Basolato, you should have access to the ducere command on your shell.

Creating projects

Using ducere you can easily create a template project structure to start development right away. Ducere will generate a folder automatically using your project name.

cd /your/project/dir
ducere new {project_name}

The overall file structure is as follows:

├── app
│   ├── data_stores
│   │   ├── queries
│   │   └── repositories
│   ├── di_container.nim
│   ├── http
│   │   ├── controllers
│   │   │   └── welcome_controller.nim
│   │   ├── middlewares
│   │   │   ├── auth_middleware.nim
│   │   │   └── set_headers_middleware.nim
│   │   └── views
│   │       ├── errors
│   │       ├── layouts
│   │       │   ├── application_view.nim
│   │       │   └── head_view.nim
│   │       └── pages
│   │           └── welcome_view.nim
│   ├── models
│   └── usecases
├── config
│   └── database.nim
├── config.nims
├── database
│   ├── migrations
│   │   └── migrate.nim
│   └── seeders
│       └── seed.nim
├── main.nim
├── public
│   ├── basolato.svg
│   ├── css
│   ├── favicon.ico
│   └── js
├── resources
│   └── lang
│       ├── en
│       │   └── validation.json
│       └── ja
│           └── validation.json
├── {project_name}.nimble
└── tests
    └── test_sample.nim

With your project ready, you can start serving requests using ducere:

ducere serve # includes hot reloading
> Run server for development

ducere build
./startServer
> Run server for production 

Documentation

English
日本語

Benchmark

benchmark

Roadmap

Version Content
v1.0 Support Clean architecture and Tactical DDD
v2.0 Support GraphQL

Development

Generate TOC of documents

Run.

nimble setupTool # Build docker image
nimble toc # Generate TOC

nim-basolato's People

Contributors

actions-user avatar agucova avatar dependabot[bot] avatar frankschmitt avatar itsumura-h avatar jiro4989 avatar kubo39 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nim-basolato's Issues

Cannot find the path specified

I am trying to create a new project named "demo" using ducere new demo command. But it is creating folder and showing some error like below.

The system cannot find the path specified.
Additional info: "("F:\\Technologies\\NIM\\Projects/demo/tmp/0.8/app", "F:\\Technologies\\NIM\\Projects/demo/app")"

image

I am new to NIM, and I can't able to understand why this error occurs and how to fix it. Any help regarding this issue will be appreciated.

Unable to install nim-basolato with nim 1.4.x

Hi there am unable to install basolato when using nim 1.4.x on ubuntu. It does however work with nim 1.2.6. Seems to be an issue with cligen

teroz@wolverine:~$ choosenim stable
      Info: Version 1.4.6 already selected
teroz@wolverine:~$ nim --version
Nim Compiler Version 1.4.6 [Linux: amd64]
Compiled at 2021-04-15
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 2b6b08032348939e5d355a6cb4faa0169306c17f
active boot switches: -d:release
teroz@wolverine:~$ nimble install https://github.com/itsumura-h/nim-basolato

Downloading https://github.com/itsumura-h/nim-basolato using git
  Verifying dependencies for [email protected]
   Warning: No .nimble or .nimble-link file found for /home/teroz/.nimble/pkgs/prologue-0.1.8
      Info: Dependency on dotenv@>= 1.1.1 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on templates@>= 0.5 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on cligen@>= 0.9.41 already satisfied
  Verifying dependencies for cligen@#head
      Info: Dependency on bcrypt@>= 0.2.1 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on nimAES@>= 0.1.2 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on flatdb@>= 0.2.4 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on redis@>= 0.3.0 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on allographer@>= 0.17.0 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on cligen@>= 0.9.38 already satisfied
  Verifying dependencies for cligen@#head
      Info: Dependency on progress@>= 1.1.1 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on dotenv@>= 1.1.1 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on faker@>= 0.13.1 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on sass@>= 0.1.0 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on interface_implements@>= 0.2.0 already satisfied
  Verifying dependencies for [email protected]
 Installing [email protected]
   Building basolato/basolato/cli/ducere using c backend
stack trace: (most recent call last)
cligen.nim(314, 27)      dispatchGen
cligen.nim(148, 31)      formalParams
cligen.nim(136, 13)      formalParamExpand
/tmp/nimble_825478/githubcom_itsumurahnimbasolato/src/basolato/cli/ducere.nim(12, 16) template/generic instantiation of `dispatchMulti` from here
/tmp/nimble_825478/githubcom_itsumurahnimbasolato/src/basolato/cli/ducere.nim(13, 13) template/generic instantiation of `dispatchMultiDG` from here
/home/teroz/.nimble/pkgs/cligen-#head/cligen.nim(136, 13) Error: multi has no param matching `suppress` key "usage"
    Prompt: Build failed for 'https://github.com/itsumura-h/[email protected]', would you like to try installing 'https://github.com/itsumura-h/nim-basolato@#head' (latest unstable)? [y/N]
    Answer:        Tip: 35 messages have been suppressed, use --verbose to show them.
     Error: Aborting installation due to build failure

Fedora is assumed as Alpine

Describe the bug

When try ducere serve, outputs /path/to/home/.asdf/installs/nim/1.4.8/nimble/pkgs/basolato-0.9.1/basolato/core/utils.nim(36, 27) Error: cannot open file: /lib/apk/db/installed

ducere serveを実行したときに、/path/to/home/.asdf/installs/nim/1.4.8/nimble/pkgs/basolato-0.9.1/basolato/core/utils.nim(36, 27) Error: cannot open file: /lib/apk/db/installedが表示される

Steps to reproduce

In Fedora 34, type ducere serve

Fedora 34で、ducere serveを実行する

Expected behavior

ldconfig -p | grep libsass would executed instead

ldconfig -p | grep libsassが代わりに実行される

Screenshots

image

Additional context

nim -> 1.4.8
basolato -> 0.9.1

cat /etc/os-release results:

NAME=Fedora
VERSION="34 (Workstation Edition)"
ID=fedora
VERSION_ID=34
VERSION_CODENAME=""
PLATFORM_ID="platform:f34"
PRETTY_NAME="Fedora 34 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:34"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/34/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=34
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=34
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation

^ As you can see, ID specifies it's fedora (from reading source code)

^ IDfedoraになってることがわかると思います。

Warning on `nimble install https://github.com/itsumura-h/nim-basolato`

summary

Show below warning when execute nimble install https://github.com/itsumura-h/nim-basolato.
Important warning is This will be an error in the future.

 Warning: Package 'flatdb' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'flatdb.nim', but a file named 'flatdbtable.nim' was found. This will be an error in the future.

Hint: If this is the primary source file in the package, rename it to 'flatdb.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'flatdb', then move it into a 'flatdb/' subdirectory. If it's a test file or otherwise not required to build the the package 'flatdb.nim', prevent its installation by adding `skipFiles = @["flatdbtable.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.

solution

Rename flatdb => flatdb.nim

But, It was concerned that existing codes written import flatdb in many files.
So, above solution will breaks existing codes.

@itsumura-h
How do you think?

ref

https://github.com/juancarlospaco/nim_packages_security_audit/blob/7914f50b18d94d4969d1fb301f2310446e09434f/f/flatdb.log#L82

V0.11.0草案

  • ミドルウェアをコントローラーに対して配列で持てるようにする
  • DIコンテナに自動で書き込まれるquery service名をキャメルケースにする
  • repositoryに import asyncdispatchを追加

TOC task

task toc, "Generate TOC":
  exec("wget https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc")
  exec("chmod +x gh-md-toc")
  exec("./gh-md-toc --insert *.md")
  exec("cd documentns")
  exec("../gh-md-toc --insert *.md")
  rmFile("gh-md-toc")
  rmFile("*.md.*")

ducere new でエラー

日本語で失礼します。
ducere newで、ディレクトリがないとエラーが出力されました。
ソースをみたところ
nim-basolato-templates
のディレクトリ構成が変更されたため、発生しているようです。
(tmp/MCVディレクトリがtmp/DDDに変更など)

ご確認ください。

description README in each layered directory

like NuxtJS

├── app
│   ├── controllers
│   │   └── REAMDE.md New!!
│   └── models
│       └── REAMDE.md New!!
├── config.nims
├── main.nim
├── middleware
│   ├── custom_headers_middleware.nim
│   ├── framework_middleware.nim
│   └── REAMDE.md New!!
├── migrations
│   ├── migrate.nim
│   ├── migration0001.nim
│   └── REAMDE.md New!!
├── public
└── resources
     └── REAMDE.md New!!

OAuth

https://github.com/CORDEA/oauth

JWTは使うべきではない 〜 SPAにおける本当にセキュアな認証方式 〜
SPAのログイン認証のベストプラクティスがわからなかったのでわりと網羅的に研究してみた〜JWT or Session どっち?〜

種類 ダメな理由
JWT 自ドメイン以外のJSから呼ばれてしまう

SPA + Rails API 構成におけるcookie + session認証

SignIn

  • get /api/signin
  • check Email and Password
  • OK =>
    • セッション作成 and login
    • return 200 with cookie
  • Fail =>
    • Http400

middleware

  • cookieのsessionIdチェック

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.