This repository has been archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88075db
commit 4974600
Showing
4 changed files
with
116 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,20 @@ | ||
# datproject.org | ||
# Dat Registry | ||
|
||
A registry for dats. [datproject.org](http://datproject.org) | ||
A web registry for the dat network. Hosted at [http://datproject.org](http://datproject.org). | ||
|
||
[![Build Status](https://travis-ci.org/datproject/datproject.org.svg?branch=master)](https://travis-ci.org/datproject/datproject.org) | ||
|
||
### Develop | ||
## Features | ||
|
||
Install dependencies. | ||
* Preview the files in a dat in the browser. | ||
* Download individual files from dats. | ||
* Create short links for dats with user accounts. | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
Create config file. | ||
|
||
You can use override the defaults by copying the example config to `config.local.js` and make changes. | ||
|
||
Initialize the database. You only have to do this once: | ||
|
||
``` | ||
node server/database/init.js | ||
``` | ||
|
||
|
||
Watch assets and start server in one command: | ||
|
||
``` | ||
npm start | ||
``` | ||
|
||
### Creating examples | ||
## Setup | ||
|
||
Run the following command to create a user with the given email address. The | ||
user will have the password `dogsandcats.` | ||
Clone this repository, then copy the default config file to `config.local.js` | ||
|
||
``` | ||
node scripts/user-and-dat.js <email-address> | ||
``` | ||
|
||
To create just dats for a given user that already exists, use | ||
``` | ||
node scripts/add-dats-for-user.js <email-address> <password> | ||
``` | ||
|
||
|
||
|
||
### Build for production | ||
``` | ||
npm run build | ||
npm run minify | ||
npm run version | ||
``` | ||
|
||
### Getting invited-users list | ||
|
||
``` | ||
git clone [email protected]:datproject/invited-users.git | ||
``` | ||
|
||
|
||
### Running end-to-end tests | ||
|
||
Docker and `docker-compose` are required. | ||
|
||
``` | ||
docker-compose build | ||
docker-compose up -d newdat && sleep 10 | ||
docker-compose run --rm nightwatch | ||
``` | ||
|
||
You may also see the test browser in action with [VNC](https://github.com/blueimp/nightwatch). | ||
|
||
## API | ||
|
||
##### ```GET /api/v1/:model``` | ||
|
||
Can pass query parameters like `?username='martha'` to filter results. | ||
|
||
Additional options: | ||
|
||
* `limit`: 100 (default) | ||
* `offset`: 0 (default) | ||
|
||
##### ```POST /api/v1/:model``` | ||
|
||
Success returns model with `id` field added. | ||
|
||
##### ```PUT /api/v1/:model?id=``` | ||
|
||
`id` required | ||
|
||
Success returns number of rows modified. | ||
``` | ||
{updated: 1} | ||
``` | ||
|
||
##### ```DELETE /api/v1/:model?id=``` | ||
|
||
`id` required | ||
|
||
Success returns number of rows deleted. | ||
``` | ||
{deleted: 1} | ||
npm install | ||
cp config/index.js config.local.js | ||
``` | ||
|
||
##### users model: ```/api/v1/users``` | ||
|
||
- `id` (required) | ||
- `email` (required) | ||
- `username` | ||
- `description` | ||
- `created_at` | ||
- `updated_at` | ||
|
||
##### dats model: ```/api/v1/dats``` | ||
|
||
- `id` | ||
- `user_id` | ||
- `name` | ||
- `title` | ||
- `hash` | ||
- `description` | ||
- `created_at` | ||
- `updated_at` | ||
|
||
##### ```/api/v1/register``` | ||
##### ```/api/v1/login``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
## API | ||
|
||
##### ```GET /api/v1/:model``` | ||
|
||
Can pass query parameters like `?username='martha'` to filter results. | ||
|
||
Additional options: | ||
|
||
* `limit`: 100 (default) | ||
* `offset`: 0 (default) | ||
|
||
##### ```POST /api/v1/:model``` | ||
|
||
Success returns model with `id` field added. | ||
|
||
##### ```PUT /api/v1/:model?id=``` | ||
|
||
`id` required | ||
|
||
Success returns number of rows modified. | ||
``` | ||
{updated: 1} | ||
``` | ||
|
||
##### ```DELETE /api/v1/:model?id=``` | ||
|
||
`id` required | ||
|
||
Success returns number of rows deleted. | ||
``` | ||
{deleted: 1} | ||
``` | ||
|
||
##### users model: ```/api/v1/users``` | ||
|
||
- `id` (required) | ||
- `email` (required) | ||
- `username` | ||
- `description` | ||
- `created_at` | ||
- `updated_at` | ||
|
||
##### dats model: ```/api/v1/dats``` | ||
|
||
- `id` | ||
- `user_id` | ||
- `name` | ||
- `title` | ||
- `hash` | ||
- `description` | ||
- `created_at` | ||
- `updated_at` | ||
|
||
##### ```/api/v1/register``` | ||
##### ```/api/v1/login``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Contributing | ||
|
||
Install dependencies. | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
Initialize the database. You only have to do this once: | ||
|
||
``` | ||
node server/database/init.js | ||
``` | ||
|
||
Watch assets and start server in one command: | ||
|
||
``` | ||
npm start | ||
``` | ||
|
||
## Creating example user and dat | ||
|
||
Run the following command to create a user with the given email address. The | ||
user will have the password `dogsandcats.` | ||
|
||
``` | ||
node scripts/user-and-dat.js <email-address> | ||
``` | ||
|
||
To create just dats for a given user that already exists, use | ||
``` | ||
node scripts/add-dats-for-user.js <email-address> <password> | ||
``` | ||
|
||
## Running end-to-end tests | ||
|
||
Docker and `docker-compose` are required. | ||
|
||
``` | ||
docker-compose build | ||
docker-compose up -d newdat && sleep 10 | ||
docker-compose run --rm nightwatch | ||
``` | ||
|
||
You may also see the test browser in action with [VNC](https://github.com/blueimp/nightwatch). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Build for production | ||
``` | ||
npm run build | ||
npm run minify | ||
npm run version | ||
``` |