Giter Site home page Giter Site logo

koa-knex-realworld-example's Introduction

RealWorld Example App

Example Node.Js (Koa.js + Knex) codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This repo is functionality complete โ€” PRs and issues welcome!

This codebase was created to demonstrate a fully fledged fullstack application built with Koa.js + Knex including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Koa.js + Knex community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

Getting started

Installation

  1. Instal Node.JS latest version
  2. Clone this repo
  3. Install dependencies, just run in project folder: npm i or yarn

Usage

  1. run npm start to start server

Testing

  1. run npm test for tests

Server Configuration (optional)

You can use .env file, to configure project like this:

NODE_ENV = development
PORT = 3000
SECRET = secret
DB_CLIENT = sqlite3
#DB_CONNECTION = postgres://user:password@localhost:5432/db_name

you can just copy .example-env

Variables description

NODE_ENV - specify env: development/production/test. development by default

NODE_PORT - specify port: 3000 by default

SECRET - custom secret for generating passwords. secret by default

DB_CLIENT - database to use. pg - postgress or sqlite3. sqlite3 by default

DB_CONNECTION - db connection string for postgress database.

Fixtures (optional)

  1. load fixtures: npm run db:load (it uses settings from .env). Don't forget to set NODE_ENV.

Styleguide

Standard - JavaScript Style Guide

How it works

Describe the general architecture of your app here

koa-knex-realworld-example's People

Contributors

alonski avatar dependabot[bot] avatar dimonnwc3 avatar edwardkcyu avatar ericsimons avatar hackergen avatar tecfu 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

koa-knex-realworld-example's Issues

comments?

Hi, do you mind if I add comments to the code?
Might help learners.

If I find time of course :)

POST /api/articles works fine on Postman but giving Unauthorized error while requesting from superagent

Here's my code:

import superagentPromise from 'superagent-promise';
import _superagent from 'superagent';

const superagent = superagentPromise(_superagent, global.Promise);
const API_ROOT = 'http://localhost:3000/api';

const Articles = {
    create: article =>
    superagent.post(`${API_ROOT}/articles`, { article })
      .set('Content-Type', 'application/json')
      .set('Authorization', `Token ${token}`)
      .set('X-Requested-With', 'XMLHttpRequest')
      .then(res => res.body)
}

This is error log of the Articles.create() function.
issue

Is there anyone who can fix this issue for me?
Thanks in advance!

NotFoundError: Not Found http-assert

Can you help me? when configuring the project and trying to exercise the user registry, I get the following error:

{ NotFoundError: Not Found
    at Object.assert (/home/marshall-mint/Documentos/JS/koa-knex-realworld-example/node_modules/http-assert/index.js:8:9)
    at module.exports (/home/marshall-mint/Documentos/JS/koa-knex-realworld-example/src/middleware/error-middleware.js:7:9)
    at process.internalTickCallback (internal/process/next_tick.js:77:7) message: 'Not Found' }

Badly written "enviroinment" to be renamed

Hello, I just found that the word "enviroinment" is badly written in "default.yml" and "custom-environment-variables.yml" config files. I think that it should be renamed into "environment".

Here are the concerned lines:

environment: config.get("env.enviroinment"),

Does not work out of the box - sqlite3 error

The code doesn't work out of box if you are using default development environment with sqlite3.

copy .example-env .env
npm start

throws the following error:
TypeError: Argument 0 must be a string
at F:\work\exp\koa\koa-knex-realworld-example\node_modules\knex\lib\dialects\sqlite3\index.js:99:16
at Client_SQLite3.acquireRawConnection (F:\work\exp\koa\koa-knex-realworld-example\node_modules\knex\lib\dialects\sqlite3\index.js:98:12)
at Object.create (F:\work\exp\koa\koa-knex-realworld-example\node_modules\knex\lib\client.js:239:16)
at Pool._createResource (F:\work\exp\koa\koa-knex-realworld-example\node_modules\generic-pool\lib\generic-pool.js:354:17)
at Pool.dispense [as _dispense] (F:\work\exp\koa\koa-knex-realworld-example\node_modules\generic-pool\lib\generic-pool.js:314:10)
at Pool.acquire (F:\work\exp\koa\koa-knex-realworld-example\node_modules\generic-pool\lib\generic-pool.js:436:8)
at F:\work\exp\koa\koa-knex-realworld-example\node_modules\knex\lib\client.js:289:19

Problem lies in the config/knexfile.js line 9:
connection: DB_CONNECTION || path.join(ROOT, 'data/dev.sqlite3'),
It should use filename for sqlite3 configuration:
connection: DB_CONNECTION || { filename: path.join(ROOT, 'data/dev.sqlite3') },

Ref: Knex Initializing the Library

Use of NODE_PATH

I was perusing the code and noticed that internal modules were referenced like how I was used to seeing npm packages referenced in required statements:
require('config')
As opposed to using the relative path:
require('./config')
I was curious, and did some digging, and learned some interesting mechanical things about cross-env, setting NODE_PATH, and Jest settings.
I'm still curious about the motivations behind this design decision, and would love to hear them

Status 422

Hi,
I am trying to run it, But this does not run.

Share with you my current error. somebody , Could help me?
Thanks!

error 422

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.