Skip to content
This repository has been archived by the owner on May 19, 2021. It is now read-only.

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fi1osof committed Oct 27, 2018
1 parent a972599 commit 189f96b
Show file tree
Hide file tree
Showing 26 changed files with 517 additions and 124 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
## Prerequisites

- [Node.js](http://nodejs.org/) >= 10 must be installed.

## Installation

- Running `yarn` in the module's root directory will install everything you need for development.

## Running Tests

- `yarn test` will run the tests once.

## Deploy prisma schema
Expand All @@ -27,5 +24,4 @@ API schema will be created also
- `yarn start`

## Building

- No building required
59 changes: 26 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,48 @@

## Upload server for [@prisma-cms](https://github.com/prisma-cms)
## Module boilerplate server for [@prisma-cms](https://github.com/prisma-cms)

### Usage

#### Standalone

Download module

```
git clone https://github.com/prisma-cms/upload-module
cd upload-module
yarn
endpoint={NEW_PRISMA_ENDPOINT} yarn deploy
endpoint={CREATED_PRISMA_ENDPOINT} yarn start
git clone https://github.com/prisma-cms/module-boilerplate
cd module-boilerplate
```
Open in brouser http://localhost:4000
Install dependencies

List of uploaded files:
`yarn install`

Update module schema

`./module-boilerplate/src/modules/schema/` (see [instruction](https://github.com/prisma-cms/boilerplate#readme))

Deploy schema to prisma-server

`endpoint={NEW_PRISMA_ENDPOINT} yarn deploy`

Start server

`endpoint={CREATED_PRISMA_ENDPOINT} yarn start`

Open in brouser http://localhost:4000

```
query filesConnection{
filesConnection(
first: 5
){
aggregate{
count
}
edges{
node{
id
path
filename
mimetype
encoding
hash
}
}
}
}
```

#### Use as module for [@prisma-cms/boilerplate](https://github.com/prisma-cms/boilerplate)

Just add as module in mergeModules here: https://github.com/prisma-cms/boilerplate/blob/master/src/server/modules/index.mjs

#### Use [uploader](https://github.com/prisma-cms/uploader) component

### [Component-boilerplate](https://github.com/prisma-cms/component-boilerplate) usage as front-end for module.

```
git clone https://github.com/prisma-cms/uploader
cd uploader
git clone https://github.com/prisma-cms/component-boilerplate
cd component-boilerplate
yarn
yarn start
```
Open in brouser http://localhost:3000

Note that upload-module should work on port 4000 or configure [proxySetup](https://github.com/prisma-cms/uploader/blob/master/src/setupProxy.js).
Note that *module-boilerplate* should work on port 4000 or configure [proxySetup](https://github.com/prisma-cms/component-boilerplate/blob/master/src/setupProxy.js).
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.1.0
===============================
- Upgrade modules

1.0.0
===============================
- First release
5 changes: 5 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore": [
"*/generated/*"
]
}
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "@prisma-cms/module-bilerplate",
"description": "Module boilerplate for @prisma-cms/server",
"version": "1.0.0-beta",
"version": "1.1.0-beta",
"main": "src/",
"files": [
"src"
],
"scripts": {
"start": "action=start-server node --experimental-modules src/server",
"deploy": "NODE_ENV=test node --experimental-modules src/server/scripts/deploy/with-prisma",
"build-api": "node --experimental-modules src/server/scripts/deploy/api-only"
"build-api": "node --experimental-modules src/server/scripts/deploy/api-only",
"test": "NODE_OPTIONS=\"--experimental-modules\" yarn mocha --delay src/__tests__/"
},
"dependencies": {
"@prisma-cms/prisma-module": "^1.1.0-beta",
"merge-graphql-schemas": "^1.5.7",
"chalk": "^2.4.1"
"@prisma-cms/prisma-module": "^1.2.0-beta",
"chalk": "^2.4.1",
"merge-graphql-schemas": "^1.5.7"
},
"devDependencies": {
"@prisma-cms/server": "^2.1.4-beta"
"@prisma-cms/server": "^2.1.6-beta",
"expect": "^23.6.0",
"mocha": "^5.2.0"
},
"resolutions": {
"graphql": "14.0.2"
Expand Down
95 changes: 95 additions & 0 deletions src/__tests__/default/module/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

import chalk from "chalk";

import CmsModule from "../../../";

import InnerModule from "./innerModule";


import path from 'path';
import MergeSchema from 'merge-graphql-schemas';

const { fileLoader, mergeTypes } = MergeSchema
const moduleURL = new URL(import.meta.url);
const __dirname = path.dirname(moduleURL.pathname);


class TestModule extends CmsModule {


constructor(options = {}) {

super(options);

this.mergeModules([
// RouterModuleExtended,
InnerModule,
]);

}


getSchema(types = []) {

let schema = fileLoader(__dirname + '/schema/database/', {
recursive: true,
});


if (schema) {
types = types.concat(schema);
}


let typesArray = super.getSchema(types);

return typesArray;

}


getApiSchema(types = []) {

/**
* Hack for imitate = "src/schema/generated/prisma.graphql";
*/
let baseSchema = this.getSchema();

// console.log("baseSchema", baseSchema);

let apiSchema = super.getApiSchema(types.concat([baseSchema]), []);

// console.log(chalk.green("TestModule apiSchema"), apiSchema);


let schema = fileLoader(__dirname + '/schema/api/', {
recursive: true,
});

// apiSchema = mergeTypes([apiSchema.concat(schema).concat(baseSchema)], { all: true });
apiSchema = mergeTypes([apiSchema.concat(schema)], { all: true });

return apiSchema;

}


getExcludableApiTypes() {

return super.getExcludableApiTypes([
// "UserCreateInput",
// "User",
// "EnumFields",
]);

}


}


export {
CmsModule as PrismaModule,
}

export default TestModule;
72 changes: 72 additions & 0 deletions src/__tests__/default/module/innerModule/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@


import chalk from "chalk";

import {PrismaModule} from "../";

import path from 'path';
import MergeSchema from 'merge-graphql-schemas';
const { fileLoader, mergeTypes } = MergeSchema
const moduleURL = new URL(import.meta.url);
const __dirname = path.dirname(moduleURL.pathname);



class InnerModule extends PrismaModule {


getSchema(types = []) {


let schema = fileLoader(__dirname + '/schema/database/', {
recursive: true,
});


console.log(chalk.green("schema"), schema);


if(schema){
types = types.concat(schema);
}


let typesArray = super.getSchema(types);

return typesArray;

}


// getApiSchema(types = []) {

// let schema = fileLoader(__dirname + '/schema/api/', {
// recursive: true,
// });

// // apiSchema = mergeTypes([apiSchema.concat(schema)], { all: true });


// return schema;

// }




getExcludableApiTypes() {

return super.getExcludableApiTypes([
// "UserCreateInput",
// "User",
// "EnumFields",
]);

}


}


export default InnerModule;

Empty file.
Empty file.
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions src/__tests__/default/module/schema/api/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


enum TestEnumFields{
TestField
}
9 changes: 9 additions & 0 deletions src/__tests__/default/module/schema/api/user.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


type TestUser {
prismaTestUsername: String
}

input TestUserCreateInput {
testUsername: String
}
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions src/__tests__/default/module/schema/database/query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


type Query {
testUsers: [TestUser!]
}
5 changes: 5 additions & 0 deletions src/__tests__/default/module/schema/database/user.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

type TestUser {
testUsername: String
prismaTestUsername: String
}
17 changes: 17 additions & 0 deletions src/__tests__/default/resolverstest.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

import expect from "expect";

import module from "./module";

const resolvers = module.getResolvers();

describe("Default module resolvers tests", () => {

it("resolvers", () => {

expect(typeof resolvers === "object").toBe(true);

});

});

Loading

0 comments on commit 189f96b

Please sign in to comment.