Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Github Actions
on:
push:
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14.x"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: npm ci
- run: npm run test
File renamed without changes.
21 changes: 21 additions & 0 deletions methods/matrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const calcDeterminant = (req, res) => {
const matrix = JSON.parse(req.query.matrix)

const rows = matrix.length
const cols = matrix[0].length

if (rows !== cols) {
res.status(500).json({ message: "Row and column counts do not match" })
}

// can assume square matrix
if (rows == 2) {
const determinant =
matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]
res.json(determinant)
} else {
res.status(500).json({ message: "Unsupported" })
}
}

module.exports = { calcDeterminant }
5 changes: 5 additions & 0 deletions methods/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const test = (req, res) => {
res.send("API call successful")
}

module.exports = { test }
Loading