-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from matheuspiment/development
first release
- Loading branch information
Showing
38 changed files
with
11,298 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"presets": ["@babel/env", "@babel/typescript"], | ||
"plugins": [ | ||
"@babel/proposal-class-properties", | ||
"@babel/proposal-object-rest-spread", | ||
"@babel/transform-runtime" | ||
] | ||
} |
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,8 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,4 @@ | ||
PORT= | ||
MONGO_URI= | ||
JWT_SECRET= | ||
GOOGLE_MAPS_API_KEY= |
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,23 @@ | ||
module.exports = { | ||
env: { | ||
es6: true, | ||
node: true, | ||
jest: true | ||
}, | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier/@typescript-eslint', | ||
'standard' | ||
], | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly' | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module' | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: {} | ||
} |
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,140 @@ | ||
|
||
# Created by https://www.gitignore.io/api/node,macos,visualstudiocode | ||
# Edit at https://www.gitignore.io/?templates=node,macos,visualstudiocode | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# react / gatsby | ||
public/ | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
|
||
# End of https://www.gitignore.io/api/node,macos,visualstudiocode | ||
|
||
mongo/ | ||
dist/ |
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,11 @@ | ||
{ | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
["@semantic-release/github", { | ||
"assets": [ | ||
{"path": "dist.zip", "label": "NodeJS distribution"}, | ||
] | ||
}], | ||
], | ||
} |
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,22 @@ | ||
language: node_js | ||
services: mongodb | ||
cache: | ||
directories: | ||
- ~/.yarn | ||
notifications: | ||
email: false | ||
node_js: | ||
- "12" | ||
before_script: | ||
- sleep 15 | ||
script: | ||
- yarn lint | ||
- yarn test | ||
- yarn build | ||
after_success: | ||
- yarn zip-dist | ||
- yarn travis-deploy-once "yarn semantic-release" | ||
- yarn report-coverage | ||
branches: | ||
only: | ||
- master |
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,2 +1,40 @@ | ||
# alumnet-developer | ||
The backend test for a developer position at Alumnet | ||
# Postfy | ||
|
||
An awesome post API. | ||
|
||
[![travis build](https://img.shields.io/travis/matheuspiment/postfy.svg)](https://travis-ci.org/matheuspiment/postfy) | ||
[![codecov coverage](https://img.shields.io/codecov/c/github/matheuspiment/postfy.svg)](https://codecov.io/gh/matheuspiment/postfy) | ||
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) | ||
|
||
- [Running the app](#running-the-app) | ||
|
||
## Running the app | ||
|
||
1. Download this repository. | ||
2. In a terminal, enter the repository folder. | ||
3. Follow the steps according to the option you want: | ||
- [Development server](#development-server). | ||
- [Production server](#production-server). | ||
|
||
### Development server | ||
|
||
#### With node | ||
|
||
1. Create a `.env` file with the content of the `.env.example`. | ||
2. Run the command `yarn install` to install the dependencies. | ||
3. A mongo database is required. You can run the `docker-compose up -d` command to setup a mongo database. Feel free to edit the `docker-compose.yml` file. | ||
4. Run the command `yarn dev`. | ||
5. Make requests to `http://localhost:<port>`, where `<port>` is the port set in the `.env` file. | ||
|
||
### Production server | ||
|
||
#### With node | ||
|
||
1. Create a `.env` file with the content of the `.env.example`. | ||
2. Run the command `yarn install` to install the dependencies. | ||
3. Run the command `yarn build`. | ||
4. A mongo database is required. You can run the `docker-compose up -d` command to setup a mongo database. Feel free to edit the `docker-compose.yml` file. | ||
5. Run the command `yarn start`. | ||
6. Make requests to `http://localhost:<port>`, where `<port>` is the port set in the `.env` file. | ||
|
||
Done! 😎 |
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,17 @@ | ||
import faker from 'faker' | ||
import { factory } from 'factory-girl' | ||
|
||
import User from '../src/schemas/User' | ||
import Post from '../src/schemas/Post' | ||
|
||
factory.define('User', User, { | ||
name: faker.name.findName(), | ||
email: faker.internet.email(), | ||
password: faker.internet.password() | ||
}) | ||
|
||
factory.define('Post', Post, { | ||
text: faker.lorem.text() | ||
}) | ||
|
||
export default factory |
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,30 @@ | ||
import '../../src/bootstrap' | ||
|
||
import mongoose from 'mongoose' | ||
|
||
class MongooseConnection { | ||
async connect (testSuitName: string): Promise<void> { | ||
mongoose.connect(`${process.env.MONGO_URI}-${testSuitName}`, { | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true, | ||
useCreateIndex: true | ||
}, async (error) => { | ||
if (error) { | ||
throw error | ||
} | ||
}) | ||
} | ||
|
||
async disconnect (): Promise<void> { | ||
await mongoose.connection.close() | ||
} | ||
|
||
async truncate (): Promise<void> { | ||
const collections = Object.keys(mongoose.connection.collections) | ||
for (const collection of collections) { | ||
await mongoose.connection.collections[collection].deleteMany({}) | ||
} | ||
} | ||
} | ||
|
||
export default new MongooseConnection() |
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,17 @@ | ||
import { Response } from 'express' | ||
|
||
function createResponseObject (): Response { | ||
return { | ||
status: function (code) { | ||
this.statusCode = code | ||
return this | ||
}, | ||
json: function () { | ||
return { | ||
status: this.statusCode | ||
} | ||
} | ||
} as Response | ||
} | ||
|
||
export default createResponseObject |
Oops, something went wrong.