Skip to content

Commit

Permalink
Changed SMS to API & tested with Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-segning committed Apr 15, 2023
1 parent 9f03218 commit c44c9cf
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 121 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@typescript-eslint/no-explicit-any": "off"
},
"ignorePatterns": [
"*.js"
"*.js",
"*gen*"
]
}
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build
on:
push:
branches:
- '*'
- '!main'
pull_request:
branches:
- '*'
- '!main'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Install Dependencies
run: yarn --silent
- name: Generate OpenAPI
run: |
yarn gen-api
- name: Build and Test
run: |
yarn build
- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: build
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ jobs:
prerelease: false
allowUpdates: true
bodyFile: CHANGELOG.md
tag: v1.0.0
tag: v1.1.0
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changelog

Here we will write every update about this project
- Changed SMS to API
8 changes: 4 additions & 4 deletions openapi-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const config: ConfigFile = {
schemaFile: './openapi.yaml',
apiFile: './src/service/empty.api.ts',
apiImport: 'emptySplitApi',
outputFile: './src/store/sms.gen.api.ts',
outputFile: './src/store/api.gen.api.ts',
outputFiles: {
'./src/store/sms.gen.api.ts': {
filterEndpoints: (operationName, operationDefinition) => operationDefinition.path.startsWith('/sms'),
'./src/store/api.gen.api.ts': {
filterEndpoints: (operationName, operationDefinition) => operationDefinition.path.startsWith('/api'),
},
},
exportName: 'smsApi',
exportName: 'apiApi',
hooks: true,
}

Expand Down
122 changes: 61 additions & 61 deletions openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
openapi: 3.0.3
info:
title: SMS API Receiver
title: API Receiver
description: |-
This is a description for the application SMS API which would mainly be a docker app. What is does, is simply a CRUD (without U) with JSON data on requests objects. So the backend is going to persist the whole request, even path and parameters.
This is a description for the application API which would mainly be a docker app. What is does, is simply a CRUD (without U) with JSON data on requests objects. So the backend is going to persist the whole request, even path and parameters.
contact:
email: dev@ssegning.com
license:
Expand All @@ -15,58 +15,58 @@ externalDocs:
servers:
- url: http://localhost:3000
tags:
- name: sms
description: Create, Delete and Read sms requests.
- name: api
description: Create, Delete and Read api requests.
externalDocs:
description: Find out more
url: https://blog.ssegning.com/tag/sms
url: https://blog.ssegning.com/tag/api
- name: config
description: Where we're going to add more config about the API (in the future)
- name: user
description: If we want to supports auth in a future, this might be helpful.
paths:
/sms:
/api:
post:
tags:
- sms
summary: Add a new sms to the store
description: Add a new sms to the store
operationId: addSmsRequest
- api
summary: Add a new api to the store
description: Add a new api to the store
operationId: addApiRequest
requestBody:
description: Create a new sms in the store
description: Create a new api in the store
content:
application/json:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
application/xml:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
required: true
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
application/xml:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
'405':
description: Invalid input
security:
- sms_auth:
- write:sms
- read:sms
- api_auth:
- write:api
- read:api
get:
tags:
- sms
summary: Finds SmsRequest
- api
summary: Finds ApiRequest
description: Multiple status values can be provided with comma separated strings
operationId: getSmsRequests
operationId: getApiRequests
parameters:
- name: query
in: query
Expand Down Expand Up @@ -102,29 +102,29 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/SmsRequestPage'
$ref: '#/components/schemas/ApiRequestPage'
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
'400':
description: Invalid status value
security:
- sms_auth:
- write:sms
- read:sms
/sms/{smsRequestId}:
- api_auth:
- write:api
- read:api
/api/{apiRequestId}:
get:
tags:
- sms
summary: Find sms by ID
description: Returns a single sms
operationId: getAnSmsRequest
- api
summary: Find api by ID
description: Returns a single api
operationId: getAnApiRequest
parameters:
- name: smsRequestId
- name: apiRequestId
in: path
description: ID of sms to return
description: ID of api to return
required: true
schema:
type: string
Expand All @@ -134,28 +134,28 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
application/xml:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
'400':
description: Invalid ID supplied
'404':
description: Sms Request not found
description: Api Request not found
security:
- sms_auth:
- write:sms
- read:sms
- api_auth:
- write:api
- read:api
delete:
tags:
- sms
summary: Deletes a sms
description: delete a sms
operationId: deleteSmsRequest
- api
summary: Deletes a api
description: delete a api
operationId: deleteApiRequest
parameters:
- name: smsRequestId
- name: apiRequestId
in: path
description: Sms Request id to delete
description: Api Request id to delete
required: true
schema:
type: string
Expand All @@ -165,23 +165,23 @@ paths:
'404':
description: Request not found
security:
- sms_auth:
- write:sms
- read:sms
- api_auth:
- write:api
- read:api
components:
schemas:
SmsRequestValue:
ApiRequestValue:
oneOf:
- type: string
- type: number
- $ref: '#/components/schemas/SmsRequest'
SmsRequest:
- $ref: '#/components/schemas/ApiRequest'
ApiRequest:
type: object
additionalProperties:
$ref: '#/components/schemas/SmsRequestValue'
$ref: '#/components/schemas/ApiRequestValue'
xml:
name: sms_request
SmsRequestPage:
name: api_request
ApiRequestPage:
type: object
required:
- content
Expand All @@ -190,7 +190,7 @@ components:
content:
type: array
items:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
meta:
$ref: '#/components/schemas/PageMeta'
PageMeta:
Expand All @@ -207,17 +207,17 @@ components:
total:
type: number
requestBodies:
SmsRequest:
description: SmsRequest object that needs to be added to the store
ApiRequest:
description: ApiRequest object that needs to be added to the store
content:
application/json:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
application/xml:
schema:
$ref: '#/components/schemas/SmsRequest'
$ref: '#/components/schemas/ApiRequest'
securitySchemes:
sms_auth:
api_auth:
type: apiKey
name: api_key
in: header
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sms-reader-frontend",
"version": "0.1.0",
"name": "api-reader-frontend",
"version": "0.2.0",
"private": true,
"dependencies": {
"@headlessui/react": "^1.7.13",
Expand Down
4 changes: 2 additions & 2 deletions public/icons/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SMS Request Watcher",
"short_name": "SMS Watcher",
"name": "Request Watcher",
"short_name": "Watcher",
"icons": [
{
"src": "/icons/android-chrome-192x192.png",
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

<meta
name="description"
content="Debug your APIs with an API watcher. Get startet with SMS only"
content="Debug your APIs with an API watcher!"
/>
<title>SMS Request Watcher</title>
<title>API Request Watcher</title>
</head>
<body class="h-full bg-gray-50">
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import { smsApi } from '../store/sms.gen.api';
import { apiApi } from '../store/api.gen.api';

interface SmsListItemProps {
interface ApiListItemProps {
idx: number;

[key: string]: any;
}

export function SmsListItem({ id, created_at, idx, ...rest }: SmsListItemProps) {
smsApi.usePrefetch('getAnSmsRequest', {});
export function ApiListItem({ id, created_at, idx, ...rest }: ApiListItemProps) {
apiApi.usePrefetch('getAnApiRequest', {});
return (
<div id={'card-' + id} className={`order-${idx} flex flex-col bg-white border shadow-sm rounded-xl mb-5`}>
<div className='overflow-y-auto p-4 md:p-5'>
Expand Down
4 changes: 2 additions & 2 deletions src/components/app-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { classNames } from '../common/class-names';

const navigation = [
{ name: 'Dashboard', href: '/' },
{ name: 'Sms Requests', href: '/sms-requests' }
{ name: 'Api Requests', href: '/api-requests' }
];

export function AppHeader() {
Expand All @@ -24,7 +24,7 @@ export function AppHeader() {
<img
className='h-8 w-8'
src='/icons/android-chrome-512x512.png'
alt='SMS API Watcher'
alt='API Watcher'
/>
</div>
<div className='hidden sm:block'>
Expand Down
Loading

0 comments on commit c44c9cf

Please sign in to comment.