Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aca.ts

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aca.ts

Aca.ts is a node.js CLI based on Typescript and Knex.js. It could automatically syncs database schema according to a custom ORM. It could also automatically generates APIs for accessing the database. More importantly, it automatically creates frontend API

  • 0.0.34
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

Aca.ts

Aca.ts is a node.js CLI based on Typescript and Knex.js. It could automatically syncs database schema according to a custom ORM. It could also automatically generates APIs for accessing the database. More importantly, it automatically creates frontend APIs through backend functions and the generated database APIs (like RPC), so frontend developers can easily access the backend without defining routing. The APIs is typescript, tips are very friendly when coding.

Use the class syntax of Typescript to define ORM:

  • Define a root namespace to represent your database
  • Define table with class (class name as table name)
  • Define column and relationship with class property (property name as column name)
  • Add constraints to table and column with decorators

An example could be found below:

example-blog.ts

namespace db {
  export class user {
    id: id
    @$_.unique name: string
    age?: int
    married = false
    profile?: profile
    posts: post[]
  }

  export class profile {
    id: id
    password: string
    @$_.foreign('userId') user: user
  }

  export class post {
    id: id
    content: string
    score: float
    @$_.foreign('userId') user: user
    categories: category[]
  }

  export class category {
    id: id
    name: string
    @$_.foreign('categoryId') parent?: category
    children: category[]
    posts: post[]
  }
}

Install

npm install -g aca.ts

Usage

  1. Create a aca project:
$ aca create <dirname>
$ cd <dirname>
  1. Open .aca directory, copy your custom ORM file into that directory, add this file name to config.json/orm field.
  1. Use the following method to create aca.ts apps:

Create a backend app (a simple koa framework):

$ aca server <dirname>

Create a frontend app (a react app with create-react-app):

$ aca client

Add self app to the project:

$ aca add <dirname> <--server or --client> --apiDir <path>
  path default: src/aca.api
  1. Generate api
$ aca up

Then the database, frontend, and backend are all set up, you can start your application now. Happy coding!

The generated backend APIs usage example are as follows:

The generated frontend APIs usage example are as follows:

Supported databases for now:

  • PostgreSQL
  • MSSQL
  • MariaDB
  • Better-Sqlite3

Keywords

FAQs

Package last updated on 23 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc