Giter Club home page Giter Club logo

koa-starter's Introduction

๐Ÿจ koa-starter

A starter kit for a slightly opinionated Koa project.

Opinions

I built this Koa starter kit because there's a number of packages I like to use when starting a new project. The major ones are:

I'm also including goodies from:

Prerequisites

Installation

  • Clone down the repository.
git clone https://github.com/snollygolly/koa-starter.git
  • Install packages (from inside the koa-starter folder).
npm install
  • Create your config. There's a config.example.json file in the root. Edit it to include all your values for the site and your OAuth information. Save it as config.json and leave it in the root.

  • If you want to use Google Analytics, set config.site.analytics to your Tracking ID and make sure the analytics partial (analytics.hbs) contains the correct Universal Analytics tracking code. If you don't want to use Google Analytics, remove that property or set it to false.

  • Start it up.

npm start
  • Enjoy!

Extras

While koa-starter isn't a framework, I've added a few small extras to make getting your project up and started as easy as possible.

Including assets from view rendering

When you render you view, you can use the following properties to link to assets.

  • Scripts: This array contains scripts living in /assets/js that you'd like to link to. The .js will be added for you.
await ctx.render("index", {
  title: config.site.name,
  user: user,
  scripts: ["index", "extra"]
});
  • Vendor JavaScript: This array contains links to external files you'd like to link to. The .js will not be added for you.
await ctx.render("index", {
  title: config.site.name,
  user: user,
  vendor_js: ["http://vendor.com/cdn/lib.min.js"]
});
  • Vendor CSS: This array contains links to external files you'd like to link to. The .css will not be added for you.
await ctx.render("index", {
  title: config.site.name,
  user: user,
  vendor_css: ["http://vendor.com/cdn/lib.min.css"]
});

Error Handling

Thrown errors are caught in the error handling middleware in index.js. By default, all errors will render the error.hbs view with information about the error. It's possible to set ctx.state.api equal to true in the controller to tell the error handling middleware that this route is an API endpoint, and the error should be sent in JSON instead of rendered as a view.

koa-starter's People

Contributors

cynical89 avatar dependabot[bot] avatar lacykerel avatar m-r-epstein avatar snollygolly 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

Watchers

 avatar  avatar  avatar  avatar  avatar

koa-starter's Issues

Please get rid of auth0

Its a paid service, why would anyone shell 800$ a month to do login on their website. Please dont do this. It is such a lovely library but getting it tied to a service like auth0 is the easiest way to sabotage the efforts that you have taken into making this

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.