Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
idipanshu committed Feb 4, 2023
0 parents commit 88e398d
Show file tree
Hide file tree
Showing 19 changed files with 1,785 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "dipanshu-firebase"
}
}
20 changes: 20 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
"on":
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_DIPANSHU_FIREBASE }}"
channelId: live
projectId: dipanshu-firebase
17 changes: 17 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on PR
"on": pull_request
jobs:
build_and_preview:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_DIPANSHU_FIREBASE }}"
projectId: dipanshu-firebase
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
.firebase
node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
10 changes: 10 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "react-ts-http",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.2.5",
"firebase": "^9.17.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^3.0.0",
"typescript": "^4.9.3",
"vite": "^4.0.0"
}
}
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getLaunches } from "./utils/getLaunches";

function App() {
const { launches } = getLaunches();

console.log(launches);

return (
<div className="App">
<h1>It works!</h1>
</div>
);
}

export default App;
17 changes: 17 additions & 0 deletions src/api/axois.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import axios from "axios";

const api = axios.create({ baseURL: "https://api.spacexdata.com/v5/" });

api.interceptors.response.use(
config => {
if (config.status === 200) {
return config.data;
}
},
error => {
console.log("Bro error ", error);
return Promise.reject(error);
}
);

export default api;
9 changes: 9 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
color-scheme: light dark;
}

body {
}
10 changes: 10 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.css'

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
18 changes: 18 additions & 0 deletions src/utils/getLaunches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useState, useEffect } from "react";
import { getLaunchCrew, LaunchResponse } from "./launches";

export const getLaunches = () => {
const [launches, setLaunches] = useState<LaunchResponse>();

useEffect(() => {
getLaunchCrew().then(res => setLaunches(res));

return () => {
setLaunches(undefined);
};
}, []);

return {
launches
};
};
82 changes: 82 additions & 0 deletions src/utils/launches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import axios from "../api/axois";

type Cores = {
core: String;
flight: Number;
gridfins: Boolean;
land_success: Boolean;
landing_intent: Boolean;
landing_type: String;
landing_vehicle: String;
legs: Boolean;
reused: Boolean;
};

type Crew = {
agency: String;
id: String;
image: String;
name: String;
status: String;
wikipedia: String;
};

type Fairings = {
recovered: Boolean;
recovery_attempt: Boolean;
reused: Boolean;
ship: String;
};

export interface LaunchResponse {
capsules: String[];
cores: Cores[];
crew: Crew[];
date_local: String;
date_precesion: String;
date_unix: Number;
date_utc: String;
details: String;
failures: [];
fairings: {};
flight_number: Number;
id: String;
launchpad: String;
links: {
article: String;
flickr: {
original: String[];
small: String[];
};
patch: {
large: String;
small: String;
};
presskit: String;
reddit: {
campaign: String;
launch: String;
media: String;
recovery: String;
};
webcast: String;
wikipedia: String;
youtube_id: String;
};
name: String;
net: Boolean;
payloads: String[];
rocket: String;
ships: [];
static_fire_date_unix: Number;
static_fire_date_utc: String;
success: Boolean;
tbd: Boolean;
upcoming: Boolean;
window: Number;
}

export const getLaunchCrew = async () => {
const response: LaunchResponse = await axios.get("/launches/latest");
return response;
};
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
Loading

0 comments on commit 88e398d

Please sign in to comment.