├── .github ├── ISSUE_TEMPLATE │ └── general-issue-or-question.md ├── actions │ ├── build │ │ └── action.yml │ └── deploy │ │ └── action.yml └── workflows │ ├── deploy-dev.yml │ └── deploy-prod.yml ├── .gitignore ├── .vscode └── symbols.json ├── LICENSE ├── README.md ├── curl ├── README.md └── generate-moon-phase.sh ├── renovate.json └── vue ├── .gitignore ├── .node-version ├── .yarnrc.yml ├── README.md ├── index.html ├── js ├── App.vue ├── app.js ├── components │ ├── CodeView.vue │ ├── GoBack.vue │ ├── MoonPhase.vue │ ├── Positions.vue │ ├── Search.vue │ └── StarChart.vue ├── mixins.js ├── routes.js └── store.js ├── package.json ├── webpack.config.js └── yarn.lock /.github/ISSUE_TEMPLATE/general-issue-or-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: General issue or question 3 | about: General questions 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please use this template to ask your question so I can answer you better 11 | 12 | ## Description of the issue 13 | 14 | ## What did you try and what didn't work 15 | 16 | ## Example code (if applicable) 17 | 18 | ## Application ID (this will help trace the logs to see what went wrong) 19 | -------------------------------------------------------------------------------- /.github/actions/build/action.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | description: Build 3 | 4 | runs: 5 | using: composite 6 | steps: 7 | - name: Install dependencies 8 | shell: bash 9 | run: | 10 | cd vue 11 | yarn install 12 | yarn build 13 | 14 | - name: Build 15 | run: | 16 | if expr "${{ inputs.target }}" : "Dev" >/dev/null; then 17 | npm run build; 18 | fi 19 | if expr "${{ inputs.target }}" : "Prod" >/dev/null; then 20 | npm run build:prod; 21 | fi 22 | shell: bash 23 | 24 | - uses: actions/upload-artifact@master 25 | with: 26 | name: buid-artifact 27 | path: vue/dist 28 | -------------------------------------------------------------------------------- /.github/actions/deploy/action.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | description: Deploy 3 | 4 | inputs: 5 | aws_access_key_id: 6 | description: AWS_ACCESS_KEY_ID 7 | required: true 8 | aws_secret_access_key: 9 | description: AWS_SECRET_ACCESS_KEY 10 | required: true 11 | aws_region: 12 | description: AWS_REGION 13 | required: true 14 | bucket_name: 15 | description: AWS_REGION 16 | required: true 17 | 18 | runs: 19 | using: composite 20 | steps: 21 | - uses: actions/download-artifact@master 22 | with: 23 | name: buid-artifact 24 | path: vue/dist 25 | 26 | - uses: jakejarvis/s3-sync-action@master 27 | with: 28 | args: --acl public-read --follow-symlinks --delete 29 | env: 30 | AWS_S3_BUCKET: ${{ inputs.bucket_name }} 31 | AWS_ACCESS_KEY_ID: ${{ inputs.aws_access_key_id }} 32 | AWS_SECRET_ACCESS_KEY: ${{ inputs.aws_secret_access_key }} 33 | AWS_REGION: ${{ inputs.aws_region }} 34 | SOURCE_DIR: "vue/dist" 35 | -------------------------------------------------------------------------------- /.github/workflows/deploy-dev.yml: -------------------------------------------------------------------------------- 1 | name: Deploy - Dev 2 | 3 | on: 4 | push: 5 | branches: ["dev"] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/setup-node@v4 12 | with: 13 | node-version: 20 14 | - run: corepack enable 15 | - uses: actions/checkout@v4 16 | - uses: ./.github/actions/build 17 | 18 | deploy: 19 | needs: build 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: ./.github/actions/deploy 24 | with: 25 | aws_account_id: ${{ secrets.AWS_ACCOUNT_ID }} 26 | aws_region: "us-east-1" 27 | bucket_name: ${{ secrets.ASTRONOMY_API_DEMO_AWS_S3_BUCKET }} 28 | -------------------------------------------------------------------------------- /.github/workflows/deploy-prod.yml: -------------------------------------------------------------------------------- 1 | name: Deploy - Prod 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/setup-node@v4 12 | with: 13 | node-version: 20 14 | - run: corepack enable 15 | - uses: actions/checkout@v4 16 | - uses: ./.github/actions/build 17 | 18 | deploy: 19 | needs: build 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v4 23 | - uses: ./.github/actions/deploy 24 | with: 25 | aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} 26 | aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 27 | aws_region: "us-east-1" 28 | bucket_name: ${{ secrets.ASTRONOMY_API_DEMO_AWS_S3_BUCKET }} 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE -------------------------------------------------------------------------------- /.vscode/symbols.json: -------------------------------------------------------------------------------- 1 | {"symbols":{},"files":{}} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Anuradha Jayathilaka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Astronomy API - Samples 2 | 3 | ### Description 4 | 5 | This repository contains various example code for the API 6 | 7 | ## vue 8 | 9 | Simple Vue js app for demoing Astronomy API. 10 | 11 | Check it live at [demo.astronomyapi.com](http://demo.astronomyapi.com) 12 | 13 | ## curl 14 | 15 | Examples with [cURL](https://curl.se) -------------------------------------------------------------------------------- /curl/README.md: -------------------------------------------------------------------------------- 1 | # Astronomy API - cURL examples 2 | 3 | ### Description 4 | 5 | Before you start obtain your `application id` and `application secret` from the API console. 6 | 7 | After your `Basic` key has been generated set it as an environment variable. 8 | 9 | ```export BASIC_AUTH_KEY=``` 10 | 11 | 12 | Run the examples by changing the params. 13 | 14 | ``` sh generate-moon-phase.sh ``` 15 | -------------------------------------------------------------------------------- /curl/generate-moon-phase.sh: -------------------------------------------------------------------------------- 1 | curl --location --request POST 'https://api.astronomyapi.com/api/v2/studio/star-chart' \ 2 | --header 'Content-Type: application/json' \ 3 | --header "Authorization: Basic ${BASIC_AUTH_KEY}" \ 4 | --data '{ 5 | "observer": { 6 | "date": "2022-02-01", 7 | "latitude": -22.05546, 8 | "longitude": 54.36588 9 | }, 10 | "style": "red", 11 | "view": { 12 | "parameters": { 13 | "constellation": "tau" 14 | }, 15 | "type": "constellation" 16 | } 17 | }' -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json" 3 | } 4 | -------------------------------------------------------------------------------- /vue/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .DS_STORE 4 | .yarn -------------------------------------------------------------------------------- /vue/.node-version: -------------------------------------------------------------------------------- 1 | 22.16.0 2 | -------------------------------------------------------------------------------- /vue/.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | -------------------------------------------------------------------------------- /vue/README.md: -------------------------------------------------------------------------------- 1 | # Astronomy API - Samples 2 | 3 | ### Description 4 | 5 | Simple Vue js app for demoing Astronomy API. 6 | 7 | Check it live at [demo.astronomyapi.com](http://demo.astronomyapi.com) 8 | 9 | ### Running locally 10 | 11 | - Clone repository 12 | - Run `npm install` to install dependencies 13 | - Run `npm run watch` to start dev server 14 | - Open `localhost:8080` in browser 15 | -------------------------------------------------------------------------------- /vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Astronomy API 11 | 13 | 14 | 15 | 16 | 19 | 20 | 21 | 79 | 80 | 81 | 82 |
83 | 84 |
85 | 86 | 87 | -------------------------------------------------------------------------------- /vue/js/App.vue: -------------------------------------------------------------------------------- 1 | 42 | 43 | 91 | -------------------------------------------------------------------------------- /vue/js/app.js: -------------------------------------------------------------------------------- 1 | import Routes from "./routes.js"; 2 | import App from "./App.vue"; 3 | 4 | const router = new VueRouter({ 5 | routes: Routes 6 | }); 7 | 8 | const app = new Vue({ 9 | router: router, 10 | components: { 11 | App: App 12 | }, 13 | el: "#app" 14 | }); 15 | -------------------------------------------------------------------------------- /vue/js/components/CodeView.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 73 | -------------------------------------------------------------------------------- /vue/js/components/GoBack.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 20 | -------------------------------------------------------------------------------- /vue/js/components/MoonPhase.vue: -------------------------------------------------------------------------------- 1 | 55 | 56 | 136 | -------------------------------------------------------------------------------- /vue/js/components/Positions.vue: -------------------------------------------------------------------------------- 1 | 79 | 80 | 140 | -------------------------------------------------------------------------------- /vue/js/components/Search.vue: -------------------------------------------------------------------------------- 1 | 56 | 57 | 112 | -------------------------------------------------------------------------------- /vue/js/components/StarChart.vue: -------------------------------------------------------------------------------- 1 | 54 | 55 | 233 | -------------------------------------------------------------------------------- /vue/js/mixins.js: -------------------------------------------------------------------------------- 1 | import { store } from "./store.js"; 2 | import HTTPSnippet from 'httpsnippet'; 3 | 4 | function objectToArray(dataObject) { 5 | return Object.keys(dataObject).filter(key => { 6 | return key != 'X-Requested-With' 7 | }) 8 | .map(key => { 9 | return { 10 | name: key, 11 | value: dataObject[key] ? dataObject[key].toString() : '' 12 | } 13 | }) 14 | } 15 | 16 | export default { 17 | methods: { 18 | checkAuth() { 19 | console.log("checkAuth"); 20 | if (!store.credentialsValid) { 21 | console.log("redirect"); 22 | this.$router.replace({ name: "home" }); 23 | } 24 | }, 25 | setSnippetData(method, 26 | url, 27 | data, 28 | headers) { 29 | store.snippet = { 30 | method, 31 | url, 32 | queryString: method == 'GET' ? objectToArray(data) : undefined, 33 | postData: method == 'POST' ? { text: JSON.stringify(data) } : undefined, 34 | headers: objectToArray(headers) 35 | } 36 | 37 | this.generateSnippet() 38 | }, 39 | generateSnippet() { 40 | const snippet = new HTTPSnippet(store.snippet); 41 | store.request = snippet.convert(store.language) 42 | }, 43 | resetCodeView() { 44 | store.request = '' 45 | store.response = '' 46 | } 47 | } 48 | }; 49 | -------------------------------------------------------------------------------- /vue/js/routes.js: -------------------------------------------------------------------------------- 1 | import App from "./App.vue"; 2 | import Positions from "./components/Positions.vue"; 3 | import StarChart from "./components/StarChart.vue"; 4 | import MoonPhase from "./components/MoonPhase.vue"; 5 | import Search from "./components/Search.vue"; 6 | 7 | export default [ 8 | { 9 | name: "home", 10 | path: "/", 11 | component: App 12 | }, 13 | { 14 | path: "/positions", 15 | component: Positions 16 | }, 17 | { 18 | path: "/star-chart", 19 | component: StarChart 20 | }, 21 | { 22 | path: "/moon-phase", 23 | component: MoonPhase 24 | }, 25 | { 26 | path: "/search", 27 | component: Search 28 | } 29 | ]; 30 | -------------------------------------------------------------------------------- /vue/js/store.js: -------------------------------------------------------------------------------- 1 | import { reactive } from "vue"; 2 | 3 | export const store = reactive({ 4 | apiEndpoint: "https://api.astronomyapi.com", 5 | appId: null, 6 | appSecret: null, 7 | credentialsValid: false, 8 | response: '', 9 | request: '', 10 | language: 'javascript', 11 | snippet: null 12 | }); 13 | -------------------------------------------------------------------------------- /vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-table", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "watch": "NODE_OPTIONS=--openssl-legacy-provider node_modules/.bin/webpack-dev-server", 8 | "build": "NODE_OPTIONS=--openssl-legacy-provider webpack", 9 | "prettier": "npx prettier --write ./js/**/*" 10 | }, 11 | "author": "", 12 | "license": "ISC", 13 | "devDependencies": { 14 | "@types/node": "^22.0.0", 15 | "babel-core": "^6.26.3", 16 | "babel-loader": "^10.0.0", 17 | "babel-preset-env": "^1.7.0", 18 | "clean-webpack-plugin": "^4.0.0", 19 | "copy-webpack-plugin": "^13.0.0", 20 | "css-loader": "^7.0.0", 21 | "html-webpack-plugin": "^5.0.0", 22 | "node-sass": "^9.0.0", 23 | "tar": ">=4.4.2", 24 | "vue": "^3.0.0", 25 | "vue-loader": "17.4.2", 26 | "vue-template-compiler": "^2.6.8", 27 | "vue-ts-loader": "0.0.3", 28 | "vue-typescript-import-dts": "^4.0.0", 29 | "webpack": "^5.0.0", 30 | "webpack-cli": "^6.0.0", 31 | "webpack-dev-server": "^5.0.0" 32 | }, 33 | "dependencies": { 34 | "httpsnippet": "^3.0.0", 35 | "lodash": "^4.17.13" 36 | }, 37 | "packageManager": "yarn@4.9.1" 38 | } 39 | -------------------------------------------------------------------------------- /vue/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require("path"); 2 | var root = path.join.bind(path, path.resolve(__dirname)); 3 | var CopyWebpackPlugin = require("copy-webpack-plugin"); 4 | var CleanWebpackPlugin = require("clean-webpack-plugin"); 5 | var HtmlWebpackPlugin = require("html-webpack-plugin"); 6 | var webpack = require("webpack"); 7 | 8 | module.exports = { 9 | entry: { 10 | app: "./js/app.js", 11 | }, 12 | output: { 13 | path: root("dist"), 14 | publicPath: "/", 15 | filename: "[name].[hash].js", 16 | chunkFilename: "[id].[hash].chunk.js", 17 | }, 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.vue$/, 22 | loader: "vue-loader", 23 | }, 24 | { 25 | test: /\.js$/, 26 | exclude: /(node_modules)/, 27 | use: { 28 | loader: "babel-loader", 29 | options: { 30 | presets: ["env"], 31 | }, 32 | }, 33 | }, 34 | { 35 | test: /\.css$/i, 36 | use: ["style-loader", "css-loader"], 37 | }, 38 | ], 39 | }, 40 | devServer: { 41 | contentBase: path.join(__dirname, "dist"), 42 | compress: true, 43 | port: 8080, 44 | }, 45 | plugins: [ 46 | new CleanWebpackPlugin(["dist/**/*.*"], { 47 | root: __dirname, 48 | verbose: true, 49 | dry: false, 50 | }), 51 | new webpack.optimize.OccurrenceOrderPlugin(), 52 | new CopyWebpackPlugin([ 53 | { 54 | from: "index.html", 55 | }, 56 | ]), 57 | new CopyWebpackPlugin([ 58 | { 59 | from: "images/**/*", 60 | }, 61 | ]), 62 | new HtmlWebpackPlugin({ 63 | template: "index.html", 64 | chunksSortMode: "dependency", 65 | inject: "body", 66 | }), 67 | new webpack.LoaderOptionsPlugin({ 68 | htmlLoader: { 69 | minimize: false, 70 | }, 71 | }), 72 | ], 73 | }; 74 | --------------------------------------------------------------------------------