9 | {/* Hero */}
10 |
11 |
19 |
20 | Fullstack Next Template
21 |
22 |
23 | Boilerplate Next.js + TypeScript + TailwindCSS dengan module alias,
24 | SVGR, ESLint, Husky, dan workflow Vercel siap pakai.
25 |
26 |
27 | {/* Credit */}
28 |
29 | by{' '}
30 |
36 | Gading Nasution
37 |
38 |
39 |
40 |
41 |
46 | ⭐ Star on GitHub
47 |
48 |
53 | 🚀 Deploy
54 |
55 |
56 |
57 |
58 | {/* Features */}
59 |
60 | Key Features
61 |
62 | -
63 | ⚛️ Next.js App Dir + TypeScript
64 |
65 | -
66 | 🎨 TailwindCSS pre-setup
67 |
68 | -
69 | 🛠️ SVGR for SVG → React
70 |
71 | -
72 | 🚦 ESLint preset & rules
73 |
74 | -
75 | 🔗 @/ Path Alias
76 |
77 |
78 |
79 |
80 | {/* Getting Started */}
81 |
82 |
83 | Getting Started
84 |
85 |
86 | git clone https://github.com/gadingnst/fullstack-next-template.git
87 | cd fullstack-next-template
88 | npm install
89 | npm run dev
90 |
91 |
92 |
93 | {/* Footer */}
94 |
99 |
100 | );
101 | }
102 |
--------------------------------------------------------------------------------
/src/modules/Quotes/services/Quote.controller.ts:
--------------------------------------------------------------------------------
1 | import QuoteModel from '@/modules/Quotes/services/Quote.model';
2 | import Controller from '@/packages/server/base/Controller';
3 |
4 | class CQuote extends Controller {
5 | /**
6 | * Use arrow function to create Controller method.
7 | * @see https://www.geeksforgeeks.org/arrow-functions-in-javascript/
8 | * @param req Request
9 | */
10 | public random = async() => {
11 | try {
12 | const payload = await QuoteModel.random();
13 | return this.sendJSON({
14 | code: 200,
15 | message: 'Success get random quote.',
16 | payload
17 | });
18 | } catch (err) {
19 | return this.handleError(err);
20 | }
21 | };
22 | }
23 |
24 | const QuoteController = new CQuote();
25 | export default QuoteController;
26 |
--------------------------------------------------------------------------------
/src/modules/Quotes/services/Quote.model.ts:
--------------------------------------------------------------------------------
1 | import { Http } from '@/packages/libs/BaseHttp';
2 |
3 | export interface IQuote {
4 | quote: string;
5 | }
6 |
7 | async function random() {
8 | const response = await Http.request('GET', 'https://quotes-api-self.vercel.app/quote');
9 | return Http.getResponseJson