Skip to content

Commit

Permalink
|#1 | @RashJrEdmund | installed express and configured base project t…
Browse files Browse the repository at this point in the history
…emplate. setup hustky, prettier, and eslint. also updated readme file
  • Loading branch information
RashJrEdmund committed Aug 10, 2024
1 parent a784455 commit 03734ca
Show file tree
Hide file tree
Showing 26 changed files with 558 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT="8080"
NODE_ENV="dev"
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"rules": {
"quotes": ["warn", "double", { "avoidEscape": true }],
"semi": ["warn", "always"],
"indent": ["warn", 2],
"class-methods-use-this": "warn",
"eol-last": ["warn", "always"],
"no-unused-vars": ["warn"],
"no-unused-expressions": ["warn"],
"no-multiple-empty-lines": ["warn", { "max": 1 }],
"no-trailing-spaces": ["warn"]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
*-lock.json

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
8 changes: 8 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [
"development"
],
"hints": {
"disown-opener": "off"
}
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run pre-commit
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.next
.cache
package-lock.json
public
node_modules
next-env.d.ts
next.config.ts
yarn.lock
src/components/ui
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
76 changes: 74 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,74 @@
# WMA_HackKmer_Yaounde_Backend
REST API server for WMA HackKmer Yaounde at Rebase Code Camp
# wiki-lex-match

__table of content__

- [local setup](#setup-repo-locally)
- [how to render the](#how-to-render-the-documentation)
- [contributing](#contributing)

## setup repo locally

- Clone repo with

```bash
git clone git@github.com:Wikidata-Cameroon/WMA_HackKmer_Yaounde_Backend.git wiki-lex-match-backend
```

- Navigate to project with from your terminal

```bash
cd wiki-lex-match-backend
```

## How to start server

- Start local server in watch mode

```bash
npm run dev
```

- Build to js

```bash
npm run build
```

## Contributing

- __Git flow__

- Branches should be name with `feature/<task>` format

- Writing commits
- Commit messages should follow the for mat `#<issue_number> | <author_name> | <work_description>`

- @example is `"|#1 | @rashjredmund | installed express and configured base project template. setup hustky, prettier, and eslint. also updated readme file"`

- The numbering is with respect to the issue number your are working on

- When creating a `PR`;

- If that pr is for an existing `issue`, be sure to tag the issue in the PR description, to auto-close the issue if it's approved, you can use any of these commands
- `Resolves #<issue_number>`
- `Fixes #<issue_number>` or
- `Closes #<issue_number>`
- Always assign the PR to yourself and your team-mate
- __Building__
- Navigate to `src/modules/<your_module_of_concern>` to start contributing
- Set up your routes in the `src/route/*` directory in the right file or add one if need be
- Set up your route handlers in the `<module-name>.controller.ts` file and add the endpoints to the corresponding route in `src/routes/*` directory
|
___
__Happy Coding Everyone 🚀__
10 changes: 10 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"watch": [
"src/"
],
"ext": "ts,json",
"ignore": [
"src/**/*.spec.ts"
],
"exec": "npx ts-node ./src/main.ts"
}
46 changes: 46 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "wiki-lex-match",
"version": "1.0.0",
"description": "The API for wiki-lex-match",
"main": "main.js",
"lint-staged": {
"src/**/*.ts": [
"npm run format"
]
},
"scripts": {
"test": "jest",
"start": "node ./dist/main.js",
"dev": "npx nodemon",
"build": "rm -rf ./dist && npx tsc",
"format": "npx prettier --config ./.prettierrc.json --write ./src",
"format:check": "npx prettier --config ./.prettierrc.json --check ./src",
"prepare": "npx husky install",
"pre-commit": "npx lint-staged"
},
"keywords": [
"wikimedia",
"lex-match",
"wiki-lex-match",
"wikicommon",
"wikidata"
],
"author": "Wiki mentor Africa Cameroon - Yaounde",
"license": "ISC",
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.21",
"@types/node": "^22.2.0",
"nodemon": "^3.1.4",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
},
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"lint-staged": "^15.2.5",
"prettier": "^3.3.3"
}
}
64 changes: 64 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="wiki-lex-match">

<meta property="og:title" content="wiki-lex-match<">
<meta property="og:description"
content="The API for wiki-lex-match, by Wiki mentor Africa Cameroon - Yaounde developer at rebase-code-camp">
<meta property="og:site_name" content="wiki-lex-match">
<meta property="og:type" content="website">

<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="wiki-lex-match">
<meta name="twitter:description"
content="The API for wiki-lex-match, by Wiki mentor Africa Cameroon - Yaounde developer at rebase-code-camp">

<script src="https://cdn.tailwindcss.com"></script>

<title>wiki-lex-match - 404 route</title>

<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
</style>
</head>

<body class="">
<main class="min-h-screen flex flex-col items-center justify-center gap-3">
<div class="flex items-center justify-center gap-2">
<h1 class="font-semibold text-[2rem] md:text-[3.4rem] lg:text-[5rem] text-blue-500">
404
</h1>

<div class="w-fit flex flex-col items-start justify-start gap-1">
<p class="text-sm text-gray-400 w-fit">
Route not found
</p>

<a href="/" class="bg-slate-900 rounded px-8 py-3 text-white cursor-pointer">
Home
</a>
</div>
</div>

<p class="text-gray-400">
cannot Get route:

<span id="route" class="text-red-500"></span>
</p>
</main>

</body>

<script defer>
document.getElementById("route").innerHTML = window.location.toString();
</script>

</html>
52 changes: 52 additions & 0 deletions public/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="wiki-lex-match">

<meta property="og:title" content="wiki-lex-match<">
<meta property="og:description"
content="The API for wiki-lex-match, by Wiki mentor Africa Cameroon - Yaounde developer at rebase-code-camp">
<meta property="og:site_name" content="wiki-lex-match">
<meta property="og:type" content="website">

<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="wiki-lex-match">
<meta name="twitter:description"
content="The API for wiki-lex-match, by Wiki mentor Africa Cameroon - Yaounde developer at rebase-code-camp">

<script src="https://cdn.tailwindcss.com"></script>

<title>wiki-lex-match</title>

<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
</style>
</head>

<body class="">
<main class="min-h-screen flex flex-col items-center justify-center">
<h1 class="font-semibold text-xl md:text-2xl text-blue-500">
welcome to wiki-lex-match
</h1>

<p class="text-sm text-gray-400">
By Wiki mentor Africa Cameroon - Yaounde developer at
<a href="https://www.linkedin.com/company/rebasecodecamp/" class="text-blue-500 cursor-pointer"
target="_blank">@rebase code camp</a>
</p>

<a href="/api-docs"
class="bg-slate-900 rounded px-8 py-3 text-white duration-300 hover:scale-[1.02] cursor-pointer mt-6">
API docs
</a>
</main>
</body>

</html>
8 changes: 8 additions & 0 deletions src/config/app-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { config } from "dotenv";

config();

export const APP_CONF = {
port: process.env.PORT!,
env: process.env.NODE_ENV as "dev" | "prod",
};
19 changes: 19 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import express, { Application } from "express";
import App from "./server";
import { APP_CONF } from "./config/app-config";

(async () => {
const app: Application = express();

const { port: PORT, env } = APP_CONF;

App(app)
.then(() =>
app.listen(PORT, () =>
console.log(
`\nserver listening on ${env === "dev" ? "http://localhost:" : "port "}${PORT}`
)
)
)
.catch(console.error);
})();
3 changes: 3 additions & 0 deletions src/middlewares/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* export middle wares from here
*/
16 changes: 16 additions & 0 deletions src/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { type RequestHandler } from "express";
import { AuthService } from "./auth.service";

export class AuthController {
private authService: AuthService;

constructor() {
this.authService = new AuthService();
}

index: RequestHandler = (req, res) => {
return res.status(200).json({
message: "Intergrade wikimedia OAuth 1.0a",
});
};
}
5 changes: 5 additions & 0 deletions src/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class AuthService {
constructor() {
//
}
}
16 changes: 16 additions & 0 deletions src/modules/languages/language.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { type RequestHandler } from "express";
import { LanguageService } from "./language.service";

export class LanguageController {
private languageService: LanguageService;

constructor() {
this.languageService = new LanguageService();
}

getAllLanguageList: RequestHandler = (req, res) => {
return res.status(200).json({
message: "return languages",
});
};
}
5 changes: 5 additions & 0 deletions src/modules/languages/language.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class LanguageService {
constructor() {
//
}
}
Loading

0 comments on commit 03734ca

Please sign in to comment.