Skip to content

Commit

Permalink
Merge pull request #5 from sv3lte/dev
Browse files Browse the repository at this point in the history
refactor: ♻️  update all topic lists' response
  • Loading branch information
sv3lte authored Jun 5, 2024
2 parents c197753 + 5fba334 commit d71b04a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 35 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# ⌨️ Conduit SSR

![version](https://img.shields.io/badge/version-0.2.0-green) [![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE) ![Koa](https://img.shields.io/badge/Koa-%5E2.14.2-fuchsia) ![JWT](https://img.shields.io/badge/JWT-%5E9.0.0-00f3e6) ![ArtTemplate](https://img.shields.io/badge/ArtTemplate-%5E4.13.2-0f83cd) ![MongoDB](https://img.shields.io/badge/MongoDB-%5E5.1.0-00ed64) ![Mongoose](https://img.shields.io/badge/Mongoose-%5E7.0.3-880000) ![pnpm](https://img.shields.io/badge/pnpm-8.15.6-f69220)

![version](https://img.shields.io/badge/version-0.2.0-green)
[![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
![Koa](https://img.shields.io/badge/Koa-%5E2.14.2-33333d)
![JWT](https://img.shields.io/badge/JWT-%5E9.0.0-00f3e6)
![ArtTemplate](https://img.shields.io/badge/ArtTemplate-%5E4.13.2-0f83cd)
![MongoDB](https://img.shields.io/badge/MongoDB-%5E5.1.0-00ed64)
![Mongoose](https://img.shields.io/badge/Mongoose-%5E7.0.3-880000)
![pnpm](https://img.shields.io/badge/pnpm-8.15.6-f69220)

## 💡 Introduction

Realworld: "The mother of all demo apps" — Exemplary SSR fullstack Medium.com clone (called [Conduit](https://github.com/yoonge/conduit-ssr)), built with Art-Template + CORS + JWT + Koa2 + MongoDB + Mongoose + TypeScript.
![pnpm-managed](https://img.shields.io/badge/pnpm-managed-f69220)
![Koa Badge](https://img.shields.io/badge/koa-2?logo=koa&logoColor=white&labelColor=%2333333d&color=white)

Besides,this repository also provides RESTful APIs for [Conduit React](https://github.com/yoonge/conduit-react).
Realworld: "The mother of all demo apps" — Exemplary SSR fullstack Medium.com clone (called [Conduit](https://github.com/yoonge/conduit-ssr)) in TypeScript, built with art-template + CORS + JWT + Koa2 + MongoDB + Mongoose.

Besides,this repository also provides RESTful APIs for [Conduit React](https://github.com/yoonge/conduit-react).

## 🔰 Getting Started

Expand All @@ -22,26 +30,19 @@ $ pnpm i
$ pnpm dev
```


<!-- ## 📁 Index -->


<!-- ## ⚡ Features -->


<!-- ## 📌 TODO -->


## 📄 License

Conduit SSR is [MIT-licensed](./LICENSE).


<!-- ## 🔗 Links -->


----

---

## 🏗️ Scaffold

Expand All @@ -52,5 +53,3 @@ $ cd conduit-ssr

$ pnpm create vite . --template vanilla-ts
```


5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"author": "Yoonge <7884008@qq.com>",
"description": "Realworld: 'The mother of all demo apps' — Exemplary SSR fullstack Medium.com clone (called Conduit), built with Art-Template + CORS + JWT + Koa2 + MongoDB + Mongoose + TypeScript.",
"description": "Exemplary SSR fullstack realworld application (called Conduit) in TypeScript, built with art-template + CORS + JWT + Koa2 + MongoDB + Mongoose, managed by pnpm.",
"keywords": [
"API",
"Art-Template",
"art-template",
"Conduit",
"CORS",
"ESLint",
Expand All @@ -13,6 +13,7 @@
"md5",
"MongoDB",
"Mongoose",
"pnpm",
"Prettier",
"RealWorld",
"RESTful",
Expand Down
Binary file added public/images/node.ico
Binary file not shown.
Binary file added public/images/nodejs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions src/api/controllers/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default class TopicCtrl {
ctx.body = {
code: 200,
msg: 'Logged out.',
formatTopics,
page: Number(page),
topics: formatTopics,
total
}
return
Expand All @@ -41,7 +42,8 @@ export default class TopicCtrl {
ctx.body = {
code: 200,
msg: 'Logged in.',
formatTopics,
page: Number(page),
topics: formatTopics,
total,
user
}
Expand Down Expand Up @@ -105,7 +107,8 @@ export default class TopicCtrl {
ctx.body = {
code: 200,
msg: 'Tag query succeed.',
formatTopics,
page: Number(page),
topics: formatTopics,
total
}
return
Expand All @@ -114,7 +117,8 @@ export default class TopicCtrl {
ctx.body = {
code: 200,
msg: 'Tag query succeed.',
formatTopics,
page: Number(page),
topics: formatTopics,
total,
user
}
Expand Down
12 changes: 8 additions & 4 deletions src/api/controllers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ export default class UserCtrl {
ctx.body = {
code: 200,
msg: 'Query my own topics succeed.',
formatTopics,
page: Number(page),
topics: formatTopics,
total,
user
}
Expand Down Expand Up @@ -202,7 +203,8 @@ export default class UserCtrl {
ctx.body = {
code: 200,
msg: 'Query my favorite topics succeed.',
formatTopics,
page: Number(page),
topics: formatTopics,
total,
user
}
Expand Down Expand Up @@ -288,7 +290,8 @@ export default class UserCtrl {
ctx.body = {
code: 200,
msg: `User ${theUser?.nickname}'s topics query succeed.`,
formatTopics,
page: Number(page),
topics: formatTopics,
theUser,
total,
user
Expand Down Expand Up @@ -322,7 +325,8 @@ export default class UserCtrl {
ctx.body = {
code: 200,
msg: `User ${theUser?.nickname}'s favorites query succeed.`,
formatTopics,
page: Number(page),
topics: formatTopics,
theUser,
total,
user
Expand Down
23 changes: 12 additions & 11 deletions test.http
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
# you'll see what happened, have fun!

@host = http://localhost:3000/api
@json = application/json


### Login
# @name loggedIn
### User Login
# @name user_login
POST {{host}}/login HTTP/1.1
content-type: application/json
content-type: {{json}}

{
"email": "one@qq.com",
"email": "yoonge@qq.com",
"password": "123456"
}


### Register
### User Register
POST {{host}}/register HTTP/1.1
content-type: application/json
content-type: {{json}}

{
"email": "q@qq.com",
Expand Down Expand Up @@ -50,24 +51,24 @@ GET {{host}}/tags/react HTTP/1.1

### User Profile, Own Topics
GET {{host}}/profile/one HTTP/1.1
Authorization: {{loggedIn.response.body.$.token}}
Authorization: {{user_login.response.body.$.token}}


### User Profile, Favorites
GET {{host}}/profile/one/favorites HTTP/1.1
Authorization: {{loggedIn.response.body.$.token}}
Authorization: {{user_login.response.body.$.token}}


### My Settings
GET {{host}}/settings HTTP/1.1
Authorization: {{loggedIn.response.body.$.token}}
Authorization: {{user_login.response.body.$.token}}


### My Topics
GET {{host}}/my-topics HTTP/1.1
Authorization: {{loggedIn.response.body.$.token}}
Authorization: {{user_login.response.body.$.token}}


### My Favorites
GET {{host}}/my-favorites HTTP/1.1
Authorization: {{loggedIn.response.body.$.token}}
Authorization: {{user_login.response.body.$.token}}

0 comments on commit d71b04a

Please sign in to comment.