npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tarsius

v0.2.2

Published

Tarsius CLI Development Tools

Downloads

2

Readme

tarsius

TARSIUS MANIFEST

Tables

Structure

tables:
  <name_table>:
    <name_field>:
      <properties>

example

tables :
  # Create table author
  author:
    id:
      type: serial
      notNull: true
      primaryKey: true
    name:
      type: varchar(100)
      notNull: true
    email:
      type: varchar(150)
      notNull: true
    created:
      type: timestamptz

Include Table

You can include table resource from other tarsius manifest

tables :
  # Create table posts
  author: ../author/tarsius.yml
  post:
    id:
      type: serial
      notNull: true
      primaryKey: true
    title:
      type: varchar(100)
      notNull: true
    content:
      type: text
    authorid:
      type: author.id # Set set authorid as a FK author table
      notNull: true
      isCascade: true
    created:
      type: timestamptz

Type Data of Field

Type | Description ---|--- bool | A Boolean data type can hold one of three possible values: true, false or null. varchar | VARCHAR(n) is the variable-length character string. int | Integer is a numeric types timestamp | TIMESTAMP stores both date and time values. timestamptz | TIMESTAMPTZ is a timezone-aware timestamp data type. It is the abbreviation for timestamp with time zone.

Properties

properties | description | value ---|---|--- type | Type data of field | String notNull | set field as a NOT NULL type | Bool primaryKey | set field as a primary key | Bool isCascade | set field as ON DELETE CASCADE and ON UPDATE CASCADE | Bool isUnique | set field as UNIQUE data | Bool

Create project

Create new project

$ mkdir project-test
$ cd project-test

Create tarsius.yml for data modeling

tables :
  # Create table author
  author:
    id:
      type: serial
      notNull: true
      primaryKey: true
    name:
      type: varchar(100)
      notNull: true
    email:
      type: varchar(150)
      notNull: true
    created:
      type: timestamptz

  # Create table post
  post:
    id:
      type: serial
      notNull: true
      primaryKey: true
    title:
      type: varchar(100)
      notNull: true
    content:
      type: text
    authorid:
      type: author.id
      notNull: true
    created:
      type: timestamptz

use anchor

tables :
  # Create table author
  author:
    id: &idAnchor
      type: serial
      notNull: true
      primaryKey: true
    name: &nameAnchor
      type: varchar(100)
      notNull: true
    email:
      <<: *nameAnchor
    created: &dateAnchor
      type: timestamptz

  # Create table post
  post:
    id:
      <<: *idAnchor
    title:
      <<: *nameAnchor
    content:
      type: text
    authorid:
      # Set joining to `authors` table
      type: author.id
      notNull: true
    created:
      <<: *dateAnchor

SQL

Configuration

$ tarsius sql config

Create table

$ tarsius sql create

Initialize your project

$ tarsius init
or
$ tarsius init -s go -p ../project-directory

Environment Variables

The generated code accepts env vars as well. They are :

  • TS_DB_HOST
  • TS_DB_PORT
  • TS_DB_NAME
  • TS_DB_USER
  • TS_DB_PASS
  • TS_CORS_ORIGIN
  • TS_CORS_METHODS
  • TS_CORS_HEADERS

TS_CORS_ORIGIN will also automaticaly sets basic CORS methods and headers. You can override them with TS_CORS_METHODS and TS_CORS_HEADERS.

Run project

$ tarsius run

Access it on http://localhost:8000

GraphQL

Query to get the all authors

query {
  authors {
    id
    name
    email
    created
  }
}

Query to get a specific author

query {
  author(id: 1) {
    id
    name
    email
  }
}

Query with pagination

query{
  authors(page:1,pageSize:4){
    id
    name
    email
  }
}

Create new author using mutation

mutation {
  createAuthor(name: "Ibnu Yahya", email: "[email protected]") {
    id
    name
    email
  }
}

Update an author using mutation

mutation {
  updateAuthor(id: 2, name: "ibnu Yahya", email: "[email protected]") {
    id
    name
    email
  }
}

Delete an author using mutation

mutation {
  deleteAuthor(id: 2) {
    id
  }
}

Query to get the posts with its relation author

query {
  posts {
    id
    title
    content
    author {
      id
      name
      email
    }
  }
}