Skip to content

Commit

Permalink
Merge pull request #12 from Speckle-Next/matteo/dev
Browse files Browse the repository at this point in the history
Matteo/dev
  • Loading branch information
didimitrie authored Jul 26, 2020
2 parents d7e3df9 + 46e6572 commit 49f05ea
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"parserOptions": {
"ecmaVersion": 11
},
"ignorePatterns": [ "modules/*/tests/*", "node_modules/*", "frontend/*"],
"rules": {
"arrow-spacing": [ 2, { "before": true, "after": true } ],
"array-bracket-spacing": [ 2, "always" ],
Expand Down
2 changes: 1 addition & 1 deletion modules/core/graph/resolvers/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = {
await validateScopes( context.scopes, 'streams:write' )
await authorizeResolver( context.userId, args.streamId, 'stream:owner' )

if ( context.userId === args.userId ) throw new AuthorizationError( 'You cannot set roles for yourself.' )
if ( context.userId === args.userId ) throw new Error( 'You cannot set roles for yourself.' )

return await grantPermissionsStream( { streamId: args.streamId, userId: args.userId, role: args.role.toLowerCase( ) || 'read' } )
},
Expand Down
2 changes: 1 addition & 1 deletion modules/core/graph/schemas/branchesAndCommits.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extend type Mutation {
branchUpdate( branch: BranchUpdateInput! ): Boolean!
branchDelete( branch: BranchDeleteInput! ): Boolean!
commitCreate( commit: CommitCreateInput! ): String!
commitUpdate( commit: CommitUpdateInput! ): String!
commitUpdate( commit: CommitUpdateInput! ): Boolean!
commitDelete( commit: CommitDeleteInput! ): Boolean!
}

Expand Down
4 changes: 2 additions & 2 deletions modules/core/graph/schemas/streams.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ extend type Mutation {
"""
streamDelete( id: String! ): Boolean!
"""
Grants permissions to an user on a given stream.
Grants permissions to a user on a given stream.
"""
streamGrantPermission( streamId: String!, userId: String!, role: String! ): Boolean
"""
Revokes the permissions of an user on a given stream.
Revokes the permissions of a user on a given stream.
"""
streamRevokePermission( streamId: String!, userId: String! ): Boolean

Expand Down
2 changes: 1 addition & 1 deletion modules/core/tests/rest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe( `Upload/Download Routes`, ( ) => {
expressApp = app

userA.id = await createUser( userA )
userA.token = `Bearer ${(await createPersonalAccessToken( userA.id, 'test token user A', [ 'streams:read', 'streams:write', 'users:read', 'users:email', 'tokens:write', 'tokens:read', 'profile:read', 'profile:email' ] ))}`
userA.token = `Bearer ${( await createPersonalAccessToken( userA.id, 'test token user A', [ 'streams:read', 'streams:write', 'users:read', 'users:email', 'tokens:write', 'tokens:read', 'profile:read', 'profile:email' ] ) )}`

testStream.id = await createStream( { ...testStream, ownerId: userA.id } )
} )
Expand Down
2 changes: 1 addition & 1 deletion modules/core/tests/users.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe( 'Actors & Tokens', ( ) => {

let match = await validatePasssword( { email: actor.email, password: 'super-test-200' } )
expect( match ).to.equal( true )
let match_wrong = await validatePasssword( { email: actor.email, password: 'super-test-2000' })
let match_wrong = await validatePasssword( { email: actor.email, password: 'super-test-2000' } )
expect( match_wrong ).to.equal( false )

} )
Expand Down
2 changes: 1 addition & 1 deletion modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.init = async ( app ) => {
} )

// Other modules preflight
moduleDirs.forEach(async dir => {
moduleDirs.forEach( async dir => {
await require( dir ).init( app )
} )

Expand Down
34 changes: 18 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,43 @@ The next iteration of the Speckle Server.

### Local debugging & testing

To debug, simply run `npm run dev`. To test, run `npm run test`. To run tests in interactive mode, run `npm run test-watch`.
To debug, simply run `npm run dev:server`. To test, run `npm run test:server`. To run tests in interactive mode, run `npm run test:server:watch`.

You will need to have a postgres instance running on the default settings, with two databases present, named `speckle2` and `speckle2_test`.
#### Requirements

1. Duplicate and rename `.env-example` to `.env`.

2. You will need to have a postgres instance running on the default settings, with two databases present, named `speckle2_dev` and `speckle2_test`.

> For getting postgres running on osx, check out [postgres.app](https://postgresapp.com/), and the classic [pgadmin](https://www.pgadmin.org/download/pgadmin-4-macos/).
### How to commit to this repo
When pushing commits to this repo, please follow the following guidelines:
3. You will also need Redis installed.

1) Install [commitizen](https://www.npmjs.com/package/commitizen#commitizen-for-contributors) globally
3) When ready to commit, type in the commandline `git cz` & follow the prompts.
> For which you can use the [redis.app](https://jpadilla.github.io/redisapp/).
## Modules
### How to commit to this repo
When pushing commits to this repo, please follow the following guidelines:

The server dynamically loads individual 'modules' from each top level folder in `./modules`. It first loads the core modules, and thereafter others ("third party").
- Install [commitizen](https://www.npmjs.com/package/commitizen#commitizen-for-contributors) globally (`npm i -g commitizen`).
- When ready to commit, type in the commandline `git cz` & follow the prompts.

### Loading
## Modules

Loading consists of two stages:
- **Preflight**: stage where a module can configure the behaviour of any shared middleware.
- **Initialisation**: final stage, where modules should hoist their routes on the core express application.
The server dynamically loads individual 'modules' from each top level folder in `./modules`. It first loads the core modules, and thereafter others.

Modules can create new and alter old database tables, if the knex migration files are present in a `migrations` subfolder (e.g., `./modules/your-module/migrations/my-new-table.js`).
Modules can create new and alter old database tables, if the knex migration files are present in a `migrations` subfolder (e.g., `./modules/your-module/migrations/my-new-table.js`). Make sure to add a date in front of your migration file.

### Structure

A module should contain in its root folder an index.js file that exposes an init function:
A module should contain in its root folder an index.js file that exposes an init function:

```js
exports.init = ( app ) => {
// Your module's initialisation code
}
```

Any database migration files should be stored and named accordingly in a `migrations` folder. Moreover, modules should include test files. These should be located in `tests`. Here's a sample structure:
Any database migration files should be stored and named accordingly in a `migrations` folder. Moreover, modules should include test files. These should be located in `tests`. Here's a sample structure:

```
Expand All @@ -62,7 +64,7 @@ Any database migration files should be stored and named accordingly in a `migrat
### GraphQl

// TODO
### REST
### REST

Depecrated.

0 comments on commit 49f05ea

Please sign in to comment.