Skip to content

Commit

Permalink
Merge pull request #195 from rajnandan1/fix/day0
Browse files Browse the repository at this point in the history
Fix/day0
  • Loading branch information
rajnandan1 authored Jan 17, 2025
2 parents a4526eb + 8c279c8 commit c2caf42
Show file tree
Hide file tree
Showing 24 changed files with 220 additions and 73 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
KENER_SECRET_KEY=please_change_me
NODE_ENV=production
PORT=3000
GH_TOKEN=your_github_token
KENER_BASE_PATH=""
RESEND_API_KEY=
ORIGIN=http://localhost:3000
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ db/*
!db/.kener
database/*
!database/.kener
uploads/*
!uploads/upload.dir

static/uploads/*
!static/uploads/upload.dir
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ RUN npm install && npm cache clean --force
# Copy the rest of the application code
COPY . .

# Ensure /app/uploads and /app/database have rw permissions
RUN mkdir -p /app/uploads /app/database && \
chmod -R 777 /app/uploads /app/database

# Build the application
RUN npm run build

# Argument for the port
ARG PORT=3000
# Set the environment variable for the port
ENV PORT=$PORT

# Expose the application port
EXPOSE $PORT

# Set the command to run the application
CMD ["node", "main"]
28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ Here are some of the features that you get out of the box. Please read the docum
- Advanced application performance monitoring tools
- Real-time network monitor software capabilities
- Polls HTTP endpoint or Push data to monitor using Rest APIs
- Handles Timezones for visitors
- Adjusts Timezones for visitors
- Categorize Monitors into different Sections
- Cron-based scheduling for monitors. Minimum per minute
- Flexible monitor configuration using YAML
- Construct complex API Polls - Chain, Secrets etc
- Supports a Default Status for Monitors
- Supports base path for hosting in k8s
- Pre-built docker image for easy deployment
- Automatically adjusts timezones for visitors

### Customization and Branding

Expand All @@ -77,36 +77,22 @@ Here are some of the features that you get out of the box. Please read the docum

- Incident Management
- Incident Communication
- Comprehensive APIs for Incident Management

### User Experience and Design

- 100% Accessibility Score
- Good Accessibility Score
- Easy installation and setup
- User-friendly interface
- Responsive design for various devices
- Auto SEO and Social Media ready
- Server Side Rendering

## Technologies used

- [SvelteKit](https://kit.svelte.dev/)
- [shadcn-svelte](https://www.shadcn-svelte.com/)

## Inspired from

- [Upptime](https://upptime.js.org/)

## Screenshots

![image](static/marken_90.png)
![image](static/marken_api.png)
![image](static/marken_badge.png)
![image](static/marken_embed.png)
![image](static/marken_inci.png)
![image](static/marken_share.png)
![image](static/marken_td.png)
![image](static/marken_tl.png)
![image](static/marken_theme.png)

## Support Me

If you are using Kener and want to support me, you can do so by sponsoring me on GitHub or buying me a coffee.
Expand All @@ -116,3 +102,7 @@ If you are using Kener and want to support me, you can do so by sponsoring me on
[Buy Me a Coffee](https://www.buymeacoffee.com/rajnandan1)

![image](https://badges.pufler.dev/visits/rajnandan1/kener)

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=rajnandan1/kener&type=Date)](https://star-history.com/#rajnandan1/kener&Date)
8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ services:
environment:
- TZ=Etc/UTC
- NODE_ENV=production
#- GH_TOKEN=
#- PORT=3000
#- KENER_BASE_PATH=
#- RESEND_API_KEY=
#- ORIGIN=
#- KENER_SECRET_KEY=
#- RESEND_SENDER_EMAIL=
#- DATABASE_URL=

# If running on a LINUX HOST and not podman rootless these MUST BE SET
# run "id $user" from command line and replace numbers below with output from command
#- PUID=1000 # gid
#- PGID=1000 # uid

### Most likely DO NOT need to change anything below this ###

Expand All @@ -26,3 +23,4 @@ services:
- '3000:3000/tcp'
volumes:
- '.:/app/database:rw'
- '.:/app/uploads:rw'
8 changes: 8 additions & 0 deletions docs/custom-js-css-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ Add your custom JS to `static/` file. And in the `src/app.html` file, add the fo

## Adding Custom CSS

Three are two ways you can add custom CSS to your Kener instance.

### CSS file

Add your custom CSS to `static/` file. And in the `src/app.html` file, add the following line:

```html
<link rel="stylesheet" href="/your-custom-css-file.css" />
```

Do not forget to add the base path if you are using a subpath. For example, if you are using a subpath `/kener`, then the path should be `/kener/your-custom-js-file.js`.

### Inline CSS

To add inline css go to Manage kener -> Theme -> Custom CSS and add your CSS there. Do not include `<style>` tags.
53 changes: 49 additions & 4 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,88 @@ docker.io/rajnandan1/kener:latest
ghcr.io/rajnandan1/kener:latest
```

You should mount two host directories to persist your configuration and database. [Environmental variables](/docs/environment-vars) can be passed with `-e` An example `docker run` command:
### Volumes

- `$(pwd)/uploads` You should mount one host directories to persist your image uploads.
- `$(pwd)/database` If you are using sqlite, you should mount one host directory to persist your database.

### Environment Variables

[Environment variables](/docs/environment-vars) can be passed with `-e` An example `docker run` command:

Make sure `./database` directory is present in the root directory.

This example is for sqlite. You can also use postgres. Read more about it [here](/docs/environment-vars/#database-url)
### Examples

This example is for sqlite. You can also use postgres. Read more about it [here](/docs/environment-vars#database-url)

#### sqlite

```bash
mkdir database
docker run \
-v $(pwd)/database:/app/database \
-v $(pwd)/uploads:/app/uploads \
-p 3000:3000 \
-e "KENER_SECRET_KEY=somesecretkey" \
-e "ORIGIN=http://localhost:3000" \
rajnandan1/kener
```

#### .env

You can also use a .env file

```bash
docker run \
-v $(pwd)/database:/app/database \
-v $(pwd)/uploads:/app/uploads \
--env-file .env \
-p 3000:3000 \
rajnandan1/kener
```

Or use **Docker Compose** with the example [docker-compose.yaml](https://raw.githubusercontent.com/rajnandan1/kener/main/docker-compose.yml)

## Base path
#### Base path

By default kener runs on `/` but you can change it to `/status` or any other path. Read more about it [here](/docs/environment-vars/#kener-base-path)

## Postgres
#### Postgres

```bash
docker run \
-p 3000:3000 \
-v $(pwd)/uploads:/app/uploads \
-e "KENER_SECRET_KEY=somesecretkey" \
-e "DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydatabase" \
-e "ORIGIN=http://localhost:3000" \
rajnandan1/kener
```

#### MySQL

```bash
docker run \
-p 3000:3000 \
-v $(pwd)/uploads:/app/uploads \
-e "KENER_SECRET_KEY=somesecretkey" \
-e "DATABASE_URL=mysql://root:password@mysql-container-2.orb.local:3306/kener-2" \
-e "ORIGIN=http://localhost:3000" \
rajnandan1/kener
```

#### Base Path

Let us say you are running kener on a subpath `/status`. You can set the base path like this:

```bash
docker run \
-p 3000:3000 \
-v $(pwd)/uploads:/app/uploads \
-e "KENER_BASE_PATH=/status" \
-e "KENER_SECRET_KEY=somesecretkey" \
-e "DATABASE_URL=mysql://root:password@mysql-container-2.orb.local:3306/kener-2" \
-e "ORIGIN=https://www.example.com" \
rajnandan1/kener
```
3 changes: 2 additions & 1 deletion docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Kener name is derived from the word "Kene" which means "how is it going" in Assa
- Handles Timezones for visitors
- Categorize Monitors into different Sections
- Cron-based scheduling for monitors. Minimum per minute
- Flexible monitor configuration using YAML
- Construct complex API Polls - Chain, Secrets etc
- Supports a Default Status for Monitors
- Supports base path for hosting in k8s
Expand All @@ -91,6 +90,7 @@ Kener name is derived from the word "Kene" which means "how is it going" in Assa

- Incident Management
- Incident Communication
- Comprehensive APIs for Incident Management

### User Experience and Design

Expand All @@ -99,6 +99,7 @@ Kener name is derived from the word "Kene" which means "how is it going" in Assa
- User-friendly interface
- Responsive design for various devices
- Auto SEO and Social Media ready
- Server Side Rendering

## Technologies used

Expand Down
10 changes: 9 additions & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ npm run dev

Kener Development Server would be running at PORT 3000. Go to [http://localhost:3000](http://localhost:3000) to see the Kener in action.

<div class="note info">

Status page will be at [http://localhost:3000](http://localhost:3000)

Status Page Manage Portal will be at [http://localhost:3000/manage/app/site](http://localhost:3000/manage/app/site)

</div>

## Create a new User

If this is the first time your are launching kener then you would be redirected to the [set up page](/manage/setup). Fill in the details and click on `Let's Go` button.
Expand All @@ -63,6 +71,6 @@ Learn how to configure kener by going through one of the topics
- [Monitors](/docs/monitors): Learn how to set up and work with monitors in kener.
- [Triggers](/docs/triggers): Learn how to set up and work with triggers in kener.
- [Environment Variables](/docs/environment-vars): Learn how to set up and work with environment variables in kener.
- [API](/docs/api): Learn how to use the API in kener.
- [API](/docs/kener-apis): Learn how to use the API in kener.
- [Databases](/docs/database): Learn how to set up and work with databases in kener.
- [Theme](/docs/theme): Learn how to set up and work with theme in kener.
6 changes: 5 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ app.get(base + "/healthcheck", (req, res) => {
res.end("ok");
});
//part /uploads server static files from static/uploads
app.use(base + "/uploads", express.static("static/uploads"));

//set env variable for upload path
process.env.UPLOAD_PATH = "./uploads";

app.use(base + "/uploads", express.static("uploads"));

try {
const openapiJSON = fs.readFileSync("./openapi.json", "utf-8");
Expand Down
8 changes: 4 additions & 4 deletions src/kener.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ section {
background: linear-gradient(0deg, var(--degraded-color) 20%, var(--up-color) 1%);
}
.bg-api-degraded-40 {
background: linear-gradient(0deg, var(--degraded-color) 20%, var(--up-color) 1%);
background: linear-gradient(0deg, var(--degraded-color) 40%, var(--up-color) 1%);
}
.bg-api-degraded-60 {
background: linear-gradient(0deg, var(--degraded-color) 20%, var(--up-color) 1%);
background: linear-gradient(0deg, var(--degraded-color) 60%, var(--up-color) 1%);
}
.bg-api-degraded-80 {
background: linear-gradient(0deg, var(--degraded-color) 20%, var(--up-color) 1%);
background: linear-gradient(0deg, var(--degraded-color) 80%, var(--up-color) 1%);
}
.bg-api-degraded-90 {
background: linear-gradient(0deg, var(--degraded-color) 20%, var(--up-color) 1%);
background: linear-gradient(0deg, var(--degraded-color) 90%, var(--up-color) 1%);
}

/*Needed to show markdown properly*/
Expand Down
14 changes: 8 additions & 6 deletions src/lib/clientTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,29 @@ const allRecordTypes = {
ANY: 255
};
const ValidateIpAddress = function (input) {
// Check if input is a valid IPv4 address
const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/;
// Check if input is a valid IPv4 address with an optional port
const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?$/;
if (ipv4Regex.test(input)) {
return "IPv4";
}

// Check if input is a valid IPv6 address
const ipv6Regex = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
// Improved IPv6 regex that better handles compressed notation
const ipv6Regex =
/^(?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){0,7}:|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){6}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|(?:[0-9a-fA-F]{1,4}:){1,7}(?::|:[0-9a-fA-F]{1,4})|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:))(?::\d{1,5})?$/;
if (ipv6Regex.test(input)) {
return "IPv6";
}

// Check if input is a valid domain name
const domainRegex = /^[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,}$/;
// Check if input is a valid domain name with an optional port
const domainRegex = /^[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,}(:\d{1,5})?$/;
if (domainRegex.test(input)) {
return "Domain Name";
}

// If none of the above conditions match, the input is invalid
return "Invalid";
};

function IsValidHost(domain) {
const regex = /^[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,}$/;
return regex.test(domain);
Expand Down
18 changes: 9 additions & 9 deletions src/lib/components/manage/monitorSheet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
};
async function saveOrUpdateMonitor() {
console.log(newMonitor);
invalidFormMessage = "";
//tag should alphanumeric hyphen underscore only
const tagRegex = /^[a-zA-Z0-9_-]+$/;
Expand Down Expand Up @@ -176,21 +175,22 @@
let hasV4 = false;
let hasV6 = false;
if (hostsV4 && Array.isArray(hostsV4) && hostsV4.length > 0) {
hostsV4.forEach((host) => {
if (ValidateIpAddress(host) == "Invalid") {
invalidFormMessage = `hostsV4 ${host} is not valid`;
for (let i = 0; i < hostsV4.length; i++) {
if (ValidateIpAddress(hostsV4[i]) == "Invalid") {
invalidFormMessage = `hostsV4 ${hostsV4[i]} is not valid`;
return;
}
});
}
hasV4 = true;
}
if (hostsV6 && Array.isArray(hostsV6) && hostsV6.length > 0) {
hostsV6.forEach((host) => {
if (ValidateIpAddress(host) == "Invalid") {
invalidFormMessage = `hostsV6 ${host} is not valid`;
for (let i = 0; i < hostsV6.length; i++) {
if (ValidateIpAddress(hostsV6[i]) == "Invalid") {
invalidFormMessage = `hostsV6 ${hostsV6[i]} is not valid`;
return;
}
});
}
hasV6 = true;
}
Expand Down
Loading

0 comments on commit c2caf42

Please sign in to comment.