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

ash-cli

v0.2.2

Published

Cli for the Ash API framework

Downloads

8

Readme

Ash Api Framework

Cli for the Ash API framework

View the API docs at https://ash-framework.github.io/core

NPM

Usage

Getting started

Before you begin

  1. Make sure you are running the latest version of node js (At least version 7)

  2. Install yarn

npm install --global yarn
  1. (optional) to use models and the data layer, postgres must be installed

Install cli

You can install the Ash cli either via yarn or npm

// option 1. via yarn
yarn global add ash-cli
// option 2. via npm
npm install --global ash-cli

Scaffold up a new project

mkdir my-awesome-project
cd my-awesome-project
ash init

Create your first route

ash generate route posts

Edit your app/routes/posts.js route file to return something from the provided model hook

// app/routes/posts.js
import Ash from 'ash-core'

export default class PostsRoute extends Ash.Route {
  model () {
    return [
      {id: 1, title: 'My post 1', description: 'WoW'},
      {id: 2, title: 'My post 2', description: 'WoWsErS'}
    ]
  }
}

Run the server

ash server

and visit the url: http://location:3010/posts

Models

Prepare your database

Create a new postgres database with a table named posts. Add 2 text fields title and description as well as a sequence id

Edit your apps database configuration in the environment config file

Add connection details to config/environment.js

module.exports = function (environment) {
  const ENV = {
    host: 'http://localhost',
    port: 3010
  }

  ENV.database = {
    connection: {
      user: '<username>',
      pass: '<password>',
      database: '<database to use>'
    }
  }

  return ENV
}

Create a Post Model

ash generate model post

Edit your app/models/post.js file to define a models attributes

// app/models/post.js
import Ash from 'ash-core'

export default class PostsRoute extends Ash.Route {
  static attributes (attr) {
    attr('title', 'string')
    attr('description', 'string')
  }
}

Update your route

Edit your app/routes/posts.js model hook, change it to return post model data

// app/routes/posts.js
import Ash from 'ash-core'

export default class PostsRoute extends Ash.Route {
  model () {
    return this.store.findAll('post')
  }
}

JSON API

Refresh: http://location:3010/posts and you should see your posts models serialized in JSON API format.

Discover the release history by heading on over to the releases page.

These amazing people are maintaining this project:

These amazing people have contributed finances to this project:

Become a sponsor!

These amazing people have contributed code to this project:

Unless stated otherwise all works are:

and licensed under: