Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up the project structure #2

Merged
merged 12 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build
.eslintrc.js
jest.config.js
app/graphql/types
module.d.ts
dist
.next
.turbo
coverage
56 changes: 56 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'plugin:typescript-sort-keys/recommended'],
plugins: ['sort-destructure-keys', 'sort-keys-fix', 'typescript-sort-keys'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: "tsconfig.json",
},
// ignorePatterns: ['.eslintrc.js'],
env: {
es6: true,
node: true,
},
rules: {
'no-var': 'warn',
semi: 'warn',
indent: ['warn', 2, { SwitchCase: 1 }],
'no-multi-spaces': 'warn',
'space-in-parens': 'warn',
'no-multiple-empty-lines': 'warn',
'prefer-const': 'warn',
'no-use-before-define': 'warn',
'max-len': ['warn', 120],
'@typescript-eslint/ban-ts-comment': [
'warn',
{
'ts-ignore': 'allow-with-description',
minimumDescriptionLength: 10
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'sort-destructure-keys/sort-destructure-keys': 2,
'@typescript-eslint/member-ordering': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/no-unused-vars': [
'warn',
{
ignoreRestSiblings: true,
},
],
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'prefer-destructuring': ['warn'],
'prefer-template': 'warn',
'object-shorthand': 'warn',
'newline-after-var': ['warn', 'always'],
curly: 'warn',
'sort-keys-fix/sort-keys-fix': 'warn',
},
};
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ testem.log
.DS_Store
Thumbs.db
notes.txt

.turbo
build/**
dist/**
.next/**
eslintcache
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
bracketSpacing: true,
bracketSameLine: false
};
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Contributing to Sharingan
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features

## Local Setup
Follow the instructions in the page below to set up the project on your local environment

[Set up Sharingan Locally](https://github.com/tericcabrel/sharingan/wiki/Local-setup)

## Pick an existing issue to contribute
Add a comment on the issue and wait for the issue to be assigned before you start working on it. This helps to avoid multiple people working on similar issues.

## Add changes in the code base
We actively welcome your pull requests, below is the process to add a change:

1- Create an issue where you explain clearly the problem you want to solve

2- Fork the repo and create your branch from `main`. Please create the branch in the format <author>/feat/<issue-name> (eg: eric/feat/add-new-auth-method)

3- If the code you added require a test, write them

4- Ensure the test suite passes.

5- Ensure the code lint succeed

6- Make a Pull Request

## Contributions License
When you submit code changes, your submissions are understood to be under the same [MIT License](https://opensource.org/licenses/MIT) that covers the project.

## Report bugs using GitHub's [issues](https://github.com/tericcabrel/sharingan/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/tericcabrel/sharingan/issues/new). It's that easy!

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

## License
By contributing, you agree that your contributions will be licensed under its AGPL v3 License.

## Questions?
Send a mail at [[email protected]](mailto:[email protected]).
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2022] [Eric Cabrel TIOGO]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# Sharingan

A code sharing web application
Sharingan is an open-source code sharing platform that makes it easy to create code snippets
and sharing it with the world.

## Key Features
* Create private or public code snippets with tags
* Browse and search into public code snippets
* Create folder to group your code snippets by category
* Generate a link to share a code snippet
* Add comments to a code snippet
* Import code snippet from GitHub Gist

## Project structure
```text
sharingan/
├─ apps/
│ ├─ core/
│ ├─ web/
├─ functions/
├─ packages/
│ ├─ common/
package.json
tsconfig.base.json
tsconfig.json
turbo.json
```

## Contributing
Kindly read our [Contributing Guide](./CONTRIBUTING.md) to learn and understand about our development process, how to propose bug fixes and improvements, and how to build and test your changes to Sharingan.

## License

This project is developed under the [MIT License](/LICENSE)
2 changes: 2 additions & 0 deletions apps/core/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HOST=http:https://localhost
PORT=7501
118 changes: 118 additions & 0 deletions apps/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### 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

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env*.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# End of https://www.toptal.com/developers/gitignore/api/node

.idea
build
69 changes: 69 additions & 0 deletions apps/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Sharingan Core

This is the core backend of Sharingan. All the business logics behind this application are implemented here.

## Tech Stack
* Node.js
* Typescript
* GraphQL
* MySQL

## Prerequisites
Make sure you have this tools installed before running the project
* Node.js 14+
* NPM or Yarn
* Docker
* AWS CLI v2

## Packages dependencies
We use Yarn workspace to create packages we can share with others applications.
These packages are located in the folder `packages` so, you can find yourself needing to change
code inside one or many packages to implement a feature. Here are the packages used in the core backend application:

* common

## Set up the project
Delete the existing folders output from build commands
```shell
yarn clean
```
Install node modules
````shell
yarn install
````
Create configuration file from the template
```shell
cp .env.template .env

# Edit configuration to match your local environment and save
nano .env
```
| Variable | Description |
|----------|------------------------------------------------------------------------|
| HOST | Host name where the application is running (default: http:https://localhost) |
| PORT | Port number of the application (default: 7500) |

Start Application
```bash
yarn dev
```
The application will be launched by [Nodemon](https://nodemon.com).

Open [http:https://localhost:7500](http:https://localhost:7500) with your browser to see the result.

## Running tests
Run the command below to run all the tests
```shell
yarn test
```
To run a specific test file, append the filename after the command
```shell
yarn test controller.test.ts
```

## Lint the project
ESLint and Prettier are used to normalize the code style across the project.
Linting the code make sure there is no error
```shell
yarn lint
```
Loading